Thanks to visit codestin.com
Credit goes to github.com

Skip to content

st.dialog shows stale elements from previous dialog #10907

@jrieke

Description

@jrieke

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

If you have two separate dialogs in your app, opening the first dialog, closing it, and then opening up the second dialog can lead to stale elements from the first dialog showing up in the second dialog. This only happens if the second dialog takes a while to load.

Screenshot.2025-03-25.at.19.33.48.mp4

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st
import time

@st.dialog("Dialog 1")
def show_dialog_1():
    st.write("Dialog 1 content")
    st.text_input("Text input")

@st.dialog("Dialog 2")
def show_dialog_2():
    time.sleep(3)
    st.write("Dialog 2 content")


if st.button("Open dialog 1"):
    show_dialog_1()

if st.button("Open dialog 2"):
    show_dialog_2()

Steps To Reproduce

  1. Open the first dialog
  2. Close it
  3. Open the second dialog

Expected Behavior

No content from show_dialog_1 shows up in show_dialog_2 since these are independent dialogs.

Current Behavior

See video.

Is this a regression?

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

Debug info

  • Streamlit version: 1.44
  • Python version:
  • Operating System:
  • Browser:

Additional Information

I think the cleanest solution might be to clear all elements from the dialog when it gets closed or opened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:frontendRelated to frontend aspectsfeature:st.dialogRelated to `st.dialog`priority:P2Medium-high priority - fix within one monthstatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions