I have an app with a fragment that runs every 5 seconds and do an API call to check for updates, if it detects an update, it’ll rerun the app. The problem is that I also have some forms in my app using dialogs. If the fragment detects an update when the user is using a dialog, the app will rerun, closing the dialog.
Because of that, I need the fragment to check if a dialog is open before running the app again.
There isn’t a native way to detect the state of the dialog. However, there are some related feature requests you might be interested in upvoting:
opened 08:25PM - 15 Sep 24 UTC
type:enhancement
feature:st.dialog
### Checklist
- [X] I have searched the [existing issues](https://github.com/st… reamlit/streamlit/issues) for similar feature requests.
- [X] I added a descriptive title and summary to this issue.
### Summary
In the streamlit community, dialogs are also used as confirmation boxes for certain use-cases. Sometimes these dialogs are meant to confirm or cancel the whole operation and should not allow the user to dismiss the confirmation box by any means.
For example, consider an `st.feedback` button which, when pressed, asks for an additional textual feedback. The user can send the feedback without any text but is still required to press the confirmation button to actually save the feedback, or discard it. Instead, if the user clicks outside of the dialog, the `st.feedback` widget has already changed its state and the user can't press it again to edit the feedback message or to delete it.
In such scenarios, it would be helpful to have a dialog which cannot be closed in any other way except by pressing the confirmation/cancellation buttons. In this way, any exception to the dialog operation can be managed and dealt with in the appropriate way. As for the feedback example, if the user clicks on the cancel button, the `st.feedback` widget could be destroyed and recreated so that the feedback shows as not sent and the widget can be interacted with again.
### Why?
Simplify exceptions and side-effects management in confirmation boxes
### How?
Add an initialization parameter, or something similar to the `form_submit_button` for forms) to prevent the dialog from being closed if not explicitly requested, or just add a way to know if it has been closed (for example by adding a key parameter to the widget)
### Additional Context
_No response_
opened 10:05AM - 16 Apr 24 UTC
type:enhancement
feature:st.fragment
### Checklist
- [X] I have searched the [existing issues](https://github.com/st… reamlit/streamlit/issues) for similar feature requests.
- [X] I added a descriptive title and summary to this issue.
### Summary
I love experimental_fragment but I really wish there was a function like `st.fragment_rerun` or something that allowed you to check for certain conditions on which to rerun that fragment on. Right now you can only do it every n seconds, and if you put a while loop to stop reruns it doesn't stop the reruns from just piling up in the queue (or at least I think that's what's going on).
Alternatively you can run `st.rerun` under a condition and just rerun the whole script but that's quite heavy handed when the point of fragments is to isolate reruns.
### Why?
_No response_
### How?
_No response_
### Additional Context
_No response_
opened 11:31PM - 15 Apr 24 UTC
type:enhancement
area:events
feature:st.dialog
### Checklist
- [X] I have searched the [existing issues](https://github.com/… streamlit/streamlit/issues) for similar feature requests.
- [X] I added a descriptive title and summary to this issue.
### 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 the `st.session_state`
### How?
Create a `key` for `st.dialog`. Use the `key` parameter to set `st.session_state.{key}-closed = True` after the dialog is closed until full execution of the app and then reset to `False`.
### 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.
system
Closed
May 4, 2025, 1:31am
3
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.