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

double click on the radio button when switch back & forth between pages #9

Closed
huamichaelchen opened this issue Nov 17, 2021 · 4 comments

Comments

@huamichaelchen
Copy link

I think the issue is with the app_state assignment.

@huamichaelchen
Copy link
Author

This is what I have tested on my own multi-page app,

Instead of st.experimental_set_query_params(**app_state), I switched to st.experimental_set_query_params(**st.session_state.to_dict())

giswqs added a commit that referenced this issue Nov 17, 2021
giswqs added a commit that referenced this issue Nov 17, 2021
@giswqs
Copy link
Member

giswqs commented Nov 17, 2021

This is a known issue related to upraneelnihar/streamlit-multiapps#2. The reason for using st.experimental_set_query_params(**app_state) is to create direct link to preselected sidebar menu, such as the link below. Changing it to t.experimental_set_query_params(**st.session_state.to_dict()) would lose the direct link functionality.

https://share.streamlit.io/giswqs/streamlit-geospatial/app.py?radio=Home&page=Create+Timelapse

@huamichaelchen
Copy link
Author

Ah, I see. Yup, the same thing happening on my end. Let me poke around ;)

@huamichaelchen
Copy link
Author

This is a known issue related to upraneelnihar/streamlit-multiapps#2. The reason for using st.experimental_set_query_params(**app_state) is to create direct link to preselected sidebar menu, such as the link below. Changing it to t.experimental_set_query_params(**st.session_state.to_dict()) would lose the direct link functionality.

https://share.streamlit.io/giswqs/streamlit-geospatial/app.py?radio=Home&page=Create+Timelapse

Not quite sure what happened... But this is how I get it to work for both the "direct link visit" issue and avoid the "double click on the radio button to switch back and forth" issue.

        pressed = st.session_state.radio 
        app_state["page"] = pressed

        st.experimental_set_query_params(**st.session_state.to_dict())
        functions[titles.index(title)]()

It seems that app_state["page"] = st.session_state.radio is the culprit? Because when I have the following:

        app_state["page"] = st.session_state.radio
        st.experimental_set_query_params(**app_state)

Direct visit works, but I have to click on the radio button twice in order to switch to a separate page. It almost as if app_state["page"] = st.session_state.radio assignment ignored the first time a radio button is pressed.

Frankly, a bit confused...

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

No branches or pull requests

2 participants