streamlit: st.tabs() error with interactive widgets

Summary

Assume that you have multiple (at least two) tabs. When you select something from a tab that is not the first one, it redirects you to the first tab. This only happens the very first time. Also, you see that any selection made is still there though.

Steps to reproduce

Open in Streamlit Cloud

Code snippet:

import streamlit as st

tab_a, tab_b, tab_c = st.tabs(["Tab-A", "Tab-B", "Tab-C"])
    with tab_a:
        toggle_a = st.radio(label="toggle_a", options=["1a", "2a", "3a"], key="unique-a")
    with tab_b:
        toggle_b = st.radio(label="toggle_b", options=["1b", "2b", "3b"], key="unique-b")
    with tab_c:
        toggle_c = st.radio(label="toggle_c", options=["1c", "2c", "3c"], key="unique-c")

If applicable, please provide the steps we should take to reproduce the bug:

  1. Go to Tab-B or Tab-C
  2. Click on any radio button under Tab-B or Tab-C

Expected behavior: No UI changes when you select something from a widget in any of the tabs.

Actual behavior:

https://user-images.githubusercontent.com/33048832/179844873-aaafc516-1430-43dc-b30d-aa81719f1d39.mov

Is this a regression?

No

Debug info

  • Streamlit version: 1.11.0
  • Python version: 3.8.12
  • Using Conda
  • OS version: macOS Monterey V12.4 and python:3.8-slim-buster (Debian GNU/Linux 10)
  • Browser version: Safari Version 15.5

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 19

Most upvoted comments

I got the same issue too.

This seems related to Safari and session_state changes. When the very first interaction with button / checkbox takes place in tab other than the first one, the app jumps back to the first tab itself.

The issue occurs for me on Chrome as well as Safari, so I don’t think the issue is just related to Safari.

Unfortunately, I’m also not able to reproduce this. I have also deployed a version on Streamlit Cloud here. @JuhyeokSin is the issue also happening with the deployed app? There was also a forum post, which might be related to this issue. But I have no clue why and when this might happen…

Hi @LukasMasuch, I just noticed that I haven’t shared my answer to one of your questions. The issue is not happening with the deployed app that you shared with me.