Checklist
Summary
If you change any parameter of a widget in Streamlit (e.g. the label or the default value), Streamlit will treat it as a new widget and reset its state. That’s necessary because we determine which widget state belongs to which widget based on the parameters. (Note that there are a few exceptions to this rule, e.g. changing the disabled parameter will not reset the widget).
But we still do this when you manually set key! Even though in that case, we can easily associate the widget state with the widget based on the key. We should change that and always preserve the widget identity if key is set.
Why?
This (potentially) fixes lots of small issues such as:
How?
We need to be careful here since this might break apps. Probably needs a bit of investigation.
Additional Context
No response
Checklist
Summary
If you change any parameter of a widget in Streamlit (e.g. the label or the default value), Streamlit will treat it as a new widget and reset its state. That’s necessary because we determine which widget state belongs to which widget based on the parameters. (Note that there are a few exceptions to this rule, e.g. changing the
disabledparameter will not reset the widget).But we still do this when you manually set
key! Even though in that case, we can easily associate the widget state with the widget based on thekey. We should change that and always preserve the widget identity ifkeyis set.Why?
This (potentially) fixes lots of small issues such as:
st.multiselectreturns empty on dynamically changing options. #7855st.selectboxsometimes ignores user input when order ofoptionschanges #8496st.data_editordoes not persist scroll position (x,y) after on_change refresh, when dependent/virtual columns are also updated #10181on_selectis provided #9527How?
We need to be careful here since this might break apps. Probably needs a bit of investigation.
Additional Context
No response