streamlit: Critical bug: Sidebar button display in page navigation
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
After clicking the button to switch_page or page_link in the sidebar of the streamlit, it will turn to the new page, but won’t disable these buttons. If we click it, an error on the web will happen.
Reproducible Code Example
# in app.py
import streamlit as st
st.sidebar.page_link("pages/omg.py", label="Next page")
# in pages/omg.py (demonstration for some AI/data processing)
import time
time.sleep(5)
Steps To Reproduce
- Run server
- Click Next button
- When it’s running on the new page, click the button on the sidebar again
Expected Behavior
The old page_link button gonna be disabled
Current Behavior
Still clickable, if there is a large processing => error. Note that is above code is just a demonstration example, I can’t give out my project code of course 😦
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.33
- Python version: 3.10
- Operating System: Ubuntu
- Browser: Brave
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 16
Ah. @juhonkang by running
st.sidebar.empty()you replace the first item in the sidebar. You’ll need to call it multiple times (as many times as the number of items in your sidebar).Separately, you can try this:
Hey @juhonkang Thanks for reaching. We considered this to be expected because we ensure the sidebar remains visible between reruns until we confirm for sure the sidebar should disappear. Otherwise, pages will have the sidebar flicker.
If you intend to keep the sidebar visible, a workaround could be to utilize
st.sidebar.empty()to clear out the element in the sidebar before you do the long computation.We are actively working on better navigation of mulipage apps in the next release or so that might provide better options associated with your use case as well. I can follow up with this later as well.
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.