Hello,
I’m using the new query_params, but it seems to be adding the keys one by one. That results in having to press the back button of the browser twice for going back to the previous page.
My code:
import streamlit as st
my_dict = dict()
my_dict['page'] = 'hello'
my_dict['bla'] = 'aha'
if st.button('test'):
st.query_params.update(my_dict)
after pressing the test button, check the back button behavior of your browser.
I’ve also tried setting st.query_params twice, one for each key. Same result. Is there any way to prevent/fix this behavior?
Note that st.query_params inherits its update method from collections.abc.MutableMapping:
>>> type(st.query_params).update
<function MutableMapping.update at 0x7e5afcc02e80>
>>> help(type(st.query_params).update)
Help on function update in module collections.abc:
update(self, other=(), /, **kwds)
D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
It’s somewhat weird that that was decided inbetween the experimental phase with st.experimental_set_query_params() and the actual launch. I hope it can be fixed. I’ve suggested a from_dict() function with an optional parameter for full replacement or merging.