I am trying to use a streamlit dropdown injunction with a query parameter in the URL such that they match at all times. So if a user selects an option in the dropdown, the URL query is updated to match and vice versa.
I tried implementing as the folllowing but it was not updating immediately and always required the user to select an option twice to update:
query_params = st.experimental_get_query_params() query_option = query_params['option'] options = ['cat', 'dog', 'mouse', 'bat', 'duck'] option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option)) st.experimental_set_query_params(option=option_selected)
If you’re wondering why i am trying to do this in the first place, my reasoning is I’d like to share a link with a specific selection to an end-user without them having to select it among the hundreds of options in the dropdown. So if there is another way to share a link with a dropdown option selected, im open to that as well.