New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rerun when dismissing st.dialog
by clicking on X or pressing Escape
#8507
Comments
I think that's a fair request in general! For your specific use case, couldn't you simply show another button after the success message that closes the dialog? I.e. something like: @st.experimental_dialog("Dialog title")
def show_dialog():
with st.form("my_form"):
...
submitted = st.form_submit_button("Submit form")
if submitted:
st.success("Yay!")
if st.button("Close"):
st.rerun() That would still show the X on the dialog, so you'd have to tell your users not to click that. We have been thinking about adding a |
Alternatively, you could also use |
st.dialog
by clicking on X or pressing Escape
Note to self: we could also turn this into an event and add something like |
This seems like a good idea but |
Yup, we just merged a PR to move them to the top right and make the font a bit bigger (see #8433). I think this should also go out in 1.34, maybe it works better then! |
Oh yeah just tried it on the nightly, it looks better but it doesn't seem to persist after the |
This is brilliant! This would perfectly fit my use case and then some. Also, for now I think I should be good with this pattern: @st.experimental_dialog("Dialog title")
def show_dialog():
with st.form("my_form"):
...
submitted = st.form_submit_button("Submit form")
if submitted:
st.success("Yay!")
if st.button("Close"):
st.rerun() I tested it and it works well! I'm all set to use this feature for our use case. Thank you for engaging! |
Ah yeah right, I think I've also seen this while testing. I mean it kinda makes sense since a rerun clears all elements from the screen. But I can see that it's annoying in this use case. Feel free to open another issue on this if you like! |
Checklist
Summary
@jrieke: Is there a way to do a rerun on x-button click or on esc key hit?
Our use case is as follows:
We use the pop up to display a form with some drop downs where user selects some options
Once the user submits the form_submit_button, we execute a Snowpark query to update backend data
Once the query is successfully executes we display a success message
On seeing the message we expect the user to close the dialog (We don't automatically close because we want the user to really see and digest the success message)
At this point we want our results on the home screen refreshed with the new results after the updates from the 2.
For this we need to be able to use the x-button submit. Is there a workaround for this use case? Since I have a form in the dialog I can't introduce a second button that executes a rerun, hence my ask to be able to capture the x-button click in
st.session_state
.Why?
I'm frustrated when I can't rerun the main app after the dialog is closed due to the
x-button
not being present in thest.session_state
How?
Create a
key
forst.dialog
. Use thekey
parameter to setst.session_state.{key}-closed = True
after the dialog is closed until full execution of the app and then reset toFalse
.Additional Context
Use case is where we use the dialog to update backend state and then want the closing of the dialog to reflect that backend state in the page that is presented once the dialog is closed.
The text was updated successfully, but these errors were encountered: