options1 = [1, 2, 3]
options2 = ["foo", "bar"]
option_central = st.selectbox("Which number do you like best?", options1)
"You selected in the central selection: ", option_central
option1_sidebar = st.sidebar.selectbox(
"Which number do you like best?", options1
)
"You selected in the sidebar:", option1_sidebar
option2_sidebar = st.sidebar.selectbox(
"Which number do you like best?", options2
)
"You selected in the sidebar:", option2_sidebar
When changing option1_sidebar the value rendered for option_central changes as well. It is as if it is somehow related to the variable which holds the list of options. If a different list/variable is used (like in option2_sidebar) the the behavior is aligned better with what I expected. Is it a bug or a feature?
Thanks, @technicalfiddles for linking to your issue, but unfortunately it was not solving my problem. Did it solve yours? If so how exactly, could you please elaborate a little?
This is somehow related to the label. If you change your code so that the strings that refer to options1 are different, this doesn’t happen. For example:
option1_sidebar = st.sidebar.selectbox(
"Which side number do you like best?", options1
)
That’s indeed solving the problem. However, this is a little un-intuitive, isn’t it? Intuitively, the caption of the selection box is meta-data of the box and should not have this side effect. Or do I miss understand something?