Skip to content
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

Getting "Could not find fragment with id 1c78f2182f4bcfbd2cda9b9971306dc7" error while calling a dialog (fragment) function from a callback. #8591

Open
3 of 4 tasks
dilipthakkar-metacube opened this issue May 1, 2024 · 3 comments
Labels

Comments

@dilipthakkar-metacube
Copy link

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Hi Team,
I'm very excited to use this feature. However with the streamlit-nightly I'm facing some issues. I want to create a feature in which I have a cancel button and on click of that cancel button I want to open a dialog with "Yes" & "No" buttons. However when I'm calling the dialog function in a button callback then I'm getting an error (Could not find fragment with id 1c78f2182f4bcfbd2cda9b9971306dc7) while clicking "Yes" or "No" button.

Reproducible Code Example

import streamlit as st

@st.experimental_dialog("Are you sure you want cancel changes?")
def show_dialog():
    def on_click_yes():
        print("yes")
        st.rerun()
        
    def on_click_no():
        print("No")
        st.rerun()
        
    cols = st.columns(2)
    with cols[0]:
        st.button("No", on_click=on_click_no)
    with cols[1]:
        st.button("Yes", on_click=on_click_yes)
         

st.button("Cancel", key="sample_key", on_click=show_dialog)

Steps To Reproduce

  1. Run the above mentioned code example.
  2. Click on the "Yes" or "No" button.
  3. You would face the above mentioned error.

Expected Behavior

It should not throw an error when we call a fragment function from a callback as it is a valid use case where I have a custom component which has a button and that button is bind with a python callback. On the click of that callback I want to show a modal to the user.

Current Behavior

It is throwing an error for fragment ID not found.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: Nightly 1.34.0
  • Python version:
  • Operating System:
  • Browser:

Additional Information

No response

@dilipthakkar-metacube dilipthakkar-metacube added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels May 1, 2024
Copy link

github-actions bot commented May 1, 2024

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@kajarenc
Copy link
Collaborator

kajarenc commented May 1, 2024

@raethlein, @vdonato, I was able to reproduce this behavior, but I think this is an expected behavior, correct?

Do we have a suggested approach to handle cases like this?

@kajarenc kajarenc added status:awaiting-team-response feature:st.dialog and removed status:needs-triage Has not been triaged by the Streamlit team labels May 1, 2024
@raethlein
Copy link
Collaborator

Cross-referencing this comment for some more context: #1360 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants