Refreash st.aggrid when button presss but hide when edit any field

dear bossThe code I have developed generates the st.aggrid upon button press. However, when the user inputs any data and presses the tab key, the st.aggrid becomes hidden and refreshes. Additionally, if the user clicks on any field with the mouse, it refreshes again, preventing the user from entering data. Please provide me with the correct code that allows user data entry, followed by a button press to refresh the st.aggrid.

see my code

import streamlit as st
import pandas as pd
from st_aggrid import AgGrid

def tt():
df = pd.DataFrame({‘name’ : [‘User 1’, ‘User 2’, ‘User 3’],
‘role’ : [‘member’, ‘admin’, ‘moderator’]})
grid_return = AgGrid(df, editable=True, theme=‘streamlit’)

if st.button(‘new record Check availability’,on_click= tt):
st.write("testing ")

dear boss
When I click on a different column, the application reverts and removes the ag-Grid. After pressing the button to display the ag-Grid again, clicking on any column results in the ag-Grid being removed once more. Could you please guide me on how to enter the data?