Hello! I am running into an issue using a dialog container in a callback function, specifically when I try to run st.rerun in the callback. The use case here is trying to populate specific information in the dialog popup based on the users selection in the dataframe. This works when switching between users but if one user is selected and then unselected (leaving no rows selected), we try to run st.rerun to close the popup when it is triggered. This yields a warning “Calling st.rerun() within a callback is a no-op.”. Based on the post here it was my understanding that this was patched in v 1.37.0. I am currently running streamlit version 1.45.0
Below is a test case - in order to reproduce the error, run using streamlit run, then click the box next to John, close the pop-up, then un-click the box next to John. Theoretically the window should close automatically, however it doesn’t and when you manually close the pop-up, the warning Calling st.rerun() within a callback is a no-op.
appears.
import streamlit as st
import pandas as pd
@st.dialog('User Info')
def callback():
idx = st.session_state['test_frame']['selection']['rows']
if idx != []:
name = st.session_state.data.loc[idx,:].iloc[0].User
st.write(f'The users Name is {name}')
else:
st.rerun()
st.session_state.data = pd.DataFrame([{'User':'John'},
{'User':'Jane'}])
st.dataframe(st.session_state.data,
key='test_frame',
on_select=callback,
selection_mode=['single-row'],
hide_index=True)