Summary
After using st.rerun
inside a tab that change its name, Streamlit force the app to the first tab.
Steps to reproduce
Code snippet:
tab2_name = "Tab 2 RERUN!" if st.session_state.pop("rerun", None) else "Tab 2"
tab_names = ["Tab 1", tab2_name]
tab1, tab2 = st.tabs(tab_names)
with tab2:
if st.button("Rerun!"):
st.session_state.rerun = True
st.rerun()
Expected behavior:
When the button is clicked, the active tab must remain the second one.
Actual behavior:
When the tab name is changed after the button was clicked, Streamlit switch the active tab to the first one.
Debug info
- Streamlit version: 1.27
- Python version: 3.10
- Browser version: Chrome, Safari, Firefox
Additional information
This bug is new with 1.27. In previous version, it wasn’t happening.