Widget's new value goes to limbo with st.experimental_get/set_query_params
See original GitHub issueSummary
I am using query_params to mirror state of widgets, so I am able to reproduce specific state with URL. I need to change state of each widget twice to get change.
Steps to reproduce
- Load state from URL with st.experimental_get_query_params
query_state = st.experimental_get_query_params()
- Set previous state as preselected value to st.radio
select_options = ['All', 'Case ID', 'Cedant', 'Doc Type']
if 'select_aggregation' in query_state:
preselected_index = find_index(select_options, lambda item: item == query_state['select_aggregation'][0])
else:
preselected_index = 0
select_aggregation = st.sidebar.radio(
label='Group by:',
options=select_options,
index=preselected_index if preselected_index > -1 else 0
)
- Store current value to query params
st.experimental_set_query_params(
select_aggregation=select_aggregation
)
- Go to view
- Click on different radio button from Group by group.
Expected behavior:
New value is selected in radio and also changed in query params
Actual behavior:
Nothing happens, at first. Value is changed in radio and also in query params after second click.
Is this a regression?
No
Debug info
- Streamlit version: 0.70.0
- Python version: 3.8.5
- Using pip and venv
- OS version: Mac OS 10.14.6
- Browser version: Chrome 86.0.4240.198 (Official Build) (x86_64)
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
Make apps bookmarkable: set query params based on widget ...
I need a way to get and set the full url in the client browser. I wan't my users to be able bookmark,...
Read more >Untitled
San francisco st louis cardinals, Antonio pico alfonso, Wp geo attack wordpress plugin, Is going outside with a fever bad, Time money value...
Read more >Untitled
Musibah new pallapa mp3, Naruto shippuden ep 286 sub! ... Is paper towns worth reading, Megan bittle st louis, Boot sector repair failed...
Read more >Untitled
Lpt pinout male, Bible community church beaufort sc, Internet on the go only ... Amputation weight calculation, Barcelona new kit messi, San remo...
Read more >List of scanned packages - SourceCode.AI
... attendancetracker attendly attest attest-latest attic attitude attr-dict ... bitcoin-utils bitcoin-value bitcoin-xyz bitcoinacceptor bitcoinaddress ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tybirk-mindway Thank you, that’s perfect. It helped a lot.
I did a few changes to mentioned workaround, because it was failing when app started with empty query params. If default query params were provided, then it worked like a charm.
So, as was mentioned here, I changed this
to this
and then I handled default state with empty query params
Then my interpretation of this code
was throwing and error, that arg 1 in eval should be string or etc. Integer was not fine. So I handled it with casting to string:
And the last change. My code inspired by this line:
was implemented like this:
because otherwise state was an integer and not list.
I hope this will help somebody.
@tomkomt @tybirk-mindway @quantoid FYI these problems likely have been solved by the recently-added callbacks functionality in Streamlit. This means that SessionState-based hacks are no longer needed to properly sync input controls with URL query params.
I have made a library of url-aware input controls that automatically sync their state with URL: streamlit-permalink.