The value displayed in the widget and the value returned by the widget get out of sync. Is this a bug, or am I doing something wrong?
import streamlit as st
if st.button("rerun"):
st.rerun()
value = st.selectbox("Select a value", ["A", "B", "C"], index=0)
st.write(f"Selected value: {value}")
Steps to reproduce
- Select
C
- Press rerun
The widget still shows C
while the actual value has been reset to A
When hitting “rerun” the script will get to the rerun() call before getting to the widget. I guess that should trigger a widget cleanup since the widget has not been rendered, unless widget cleanup does not happen when rerun is called manually. In any case, the displayed value in the select box should be the same as the value returned in the python script.
Streamlit version: 1.40.1
local run