Stop switching tabs when I am adding in a new variable in tab

Hi all.

I’ve currently got some tabs I would wish to show alternative graphics within, specifically some plotly plots. I’ve made the tabs so that the names are:

default_tab, distribution_tab = st.tabs(["Historical Comparison - Violin", "Historical Comparison - Distribution"])

With this in mind, I am trying to make in the “Historical Comparison - Distribution” tab, some plotly plots like this:

with distribution_tab:
    if analysis_option == "Manual":

        efa_option = st.selectbox(
            "Please select the efa block you wish to view",
            (1,2,3,4,5,6),
        )

        complementary_option = st.selectbox(
            "Please select the complementary plot with the distribution",
            ("rug", "box", "violin"),
        )
        st.write(
            f"EFA {efa_option} Distribution"
        )

        efa_input_dat = df_input["Clearing Price"][df_input["EFA"] == efa_option].to_frame()
        efa_input_dat['type'] = 'Filtered'
        efa_default_dat = df_default["Clearing Price"][df_default["EFA"] == efa_option].to_frame()
        efa_default_dat['type'] = 'Total'
        total_df = pd.concat([efa_input_dat, efa_default_dat])
        fig = px.histogram(total_df, x="Clearing Price", color="type", marginal=complementary_option)
        st.plotly_chart(fig)

Now, within this tab I can get the data I want fine, but whenever I try to change the value of efa_option selectbox it switches back to the “Historical Comparison - Violin” tab.

I was wondering whether there was a wat to prevent this automatic tab reversal?

Thanks in advance!

Hey @sang_young_noh, Thanks for reporting this issue! Unfortunately, I wasn’t able to reproduce this problem with the provided snippet. Changing the value of efa_option selectbox does not switch the tab for me. Do you have a video/gif showing the tab switching issue or a full code snippet?