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

Critical bug: Sidebar button display in page navigation #8589

Open
3 of 4 tasks
juhonkang opened this issue Apr 30, 2024 · 12 comments
Open
3 of 4 tasks

Critical bug: Sidebar button display in page navigation #8589

juhonkang opened this issue Apr 30, 2024 · 12 comments
Labels
feature:multipage-apps status:awaiting-user-response Issue requires clarification from submitter type:bug Something isn't working

Comments

@juhonkang
Copy link

juhonkang commented Apr 30, 2024

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

  1. Run server
  2. Click Next button
  3. 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

@juhonkang juhonkang added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Apr 30, 2024
Copy link

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 kajarenc added feature:multipage-apps and removed status:needs-triage Has not been triaged by the Streamlit team labels May 2, 2024
@kajarenc
Copy link
Collaborator

kajarenc commented May 2, 2024

Hey @juhonkang , and thank you for opening this issue.

Unfortunately, I couldn't reproduce this issue on my local machine. Does this issue still exist on your local / deployed app?

@kmcgrady This could be something similar to that Heisenbug you faced once.

@kajarenc kajarenc added the status:awaiting-user-response Issue requires clarification from submitter label May 2, 2024
@juhonkang
Copy link
Author

juhonkang commented May 2, 2024 via email

@juhonkang
Copy link
Author

@kajarenc Hi, do you have good news for me :)

@kajarenc
Copy link
Collaborator

Hey, @juhonkang!

We discussed this issue with @kmcgrady. I don't remember the details, but he probably has a more detailed answer.

In the meantime, a small question: Does the problem persist if you set showSidebarNavigation = false in the config.toml for your case (https://docs.streamlit.io/develop/api-reference/configuration/config.toml)?

@juhonkang
Copy link
Author

image
Yes, I do have it in my project from start @kajarenc @kmcgrady !!!

@kmcgrady
Copy link
Collaborator

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.

@juhonkang
Copy link
Author

@kmcgrady Sure, let me try it!

@juhonkang
Copy link
Author

@kmcgrady All others in the sidebar will disappear, except the button of next page on it.
if st.sidebar.button("Click me"): st.switch_page("pages/omg.py")
or
st.sidebar.switch_page("pages/omg.py", label="Omg")

@kmcgrady
Copy link
Collaborator

Hey @juhonkang I'm not sure if I understand the comment. Are you saying that st.empty() will remove all elements but the omg page button?

@juhonkang
Copy link
Author

@kmcgrady Yes, all other buttons will be empty with st.sidebar.empty() except the button changing the pages clicked.

For example, the button to change the page is "omg" Here in my example is clicked to switch pages and it will appear on the next page and be clickable although all other components on the sidebar for example selectbox gone.

@kmcgrady
Copy link
Collaborator

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:

my_sidebar = st.sidebar.empty()
my_sidebar = my_sidebar.container()

# replace all calls of st.sidebar with my_sidebar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:multipage-apps status:awaiting-user-response Issue requires clarification from submitter type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants