[BUG 1.27] Change name to a tab after a rerun, switch to the first tab

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.

Thanks for reporting, @Mortafix! :pray:

If this code was indeed working in a previous version and doesn’t work with 1.27, it indeed seems like a :bug:! :slight_smile:

Would you mind opening a ticket on GitHub, please?

Best,
Charly

1 Like

Thanks for the reply, @Charly_Wargnier! :pray:

I opened an issue on GitHub, HERE.

1 Like

That’s great, thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.