I have several buttons within a dialog. Even when they don’t do anything, clicking them gives the following error.
The button within the dialog is defined as st.button("Select",key=1)
When clicked, everything disappears from the dialog (except the label), and I get the error RuntimeError: Could not find fragment with id 1c78f2182f4bcfbd2cda9b9971306dc7
This is true for all of the buttons in the dialog, even though I haven’t yet written the code that defines what should happen once their pressed. My assumption is that clicking the button causes the whole page to rerun and streamlit is losing track of the items in the dialog.
import streamlit as st
st.title("Text outside of dialog box")
@st.experimental_dialog("Test Dialog")
def dialog_box():
st.write("Text in dialog box")
st.button("Press me to see error")
st.button("Show dialog box", on_click=dialog_box)
After a look at the documentation I would say this is a bug. However, I am not sure that opening dialogs from callbacks is intended to be supported.
FWIW I often see unexpected behavior when I create streamlit widgets from callbacks, so I just don’t do it anymore. Instead I use callbacks to change state, then create widgets outside the callbacks, based on the state.
Whenever I typed in email in the dialog, I will see the same fragment not found error
Traceback (most recent call last):
File “/Users/jocelinho/Documents/Jocelin/Projects/lawsome/venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 595, in _run_script
raise RuntimeError(
RuntimeError: Could not find fragment with id 1c78f2182f4bcfbd2cda9b9971306dc7
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.