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