Skip to content

BUG: Stale widgets from previous page runs are not removed when a spinner is later invoked #14404

@connortann

Description

@connortann

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

In certain circumstances, UI elements from previous page executions unexpectedly remain on the screen.

This is possibly related to #14249 , which was apparently caused by a recent change #13849 and fixed by #14251. However, this bug occurs in a slightly context, without use of tabs or cached functions, so I think it's a distinct issue.

I've boiled down a minimal reproducible example below. The bug seems to occur if a call to st.spinner is made after a selection widget, and the precise behaviour varies depending on whether Expander containers are used and whether other objects are rendered before the spinner.

I noticed two slight variants of this bug, depending on whether some markdown is rendered before the call to st.spinner. In each cases a different stale widget is left:

Variant 1: without markdown call

As per the code example below: the "Button 1" widget (and Expander box) remains visible, but the "Button 2" widget is cleared.

bug_spinner_A.webm

Variant 2: with markdown call

As above but uncommenting the call to st.markdown: now the "Button 1" widget is indeed cleaned up properly, but the "Button 2" widget is now erroneously left.

bug_spinner_B.webm

Reproducible Code Example

import streamlit as st

st.write("Streamlit version:", st.__version__)

choice = st.radio("Radio", options=["A", "B"])
if choice == "B":
    with st.expander("Inner", expanded=True):
        st.button("Button 1")
    st.button("Button 2")

# Uncommenting this line changes the behaviour of the bug:
# st.markdown("Some text")

with st.spinner():
    pass

Steps To Reproduce

  1. Click "B"
  2. Click "A"

Expected Behavior

When "A" is selected, the Expander and Button widgets should be hidden.

Current Behavior

When "A" is selected, the Expander box and "Button 1" Button remain visible.

Is this a regression?

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

Debug info

  • Streamlit version: 1.55.0
  • Python version: 3.10
  • Operating System: Linux
  • Browser: Chrome

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triageIssue has not been triaged 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