-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Summary
In a selectbox, when I select an item, it oftentimes (but not always) very briefly shows the new select item but then changes back to the previous selection. I am not sure what causes this, because my code is fairly straightforward. You can see this live in the demo here. Just change the Source language a couple of times and it should become clear.
Steps to reproduce
Code snippet:
The code is a bit verbose. First it gets a full name for a select language (e.g. en -> English, where en is session state src_lang and English will be selected_full_src_lang). Then it creates the selectbox, with the current language selected, based on its index in a list of languages. Then, when a src_lang is selected, its language abbreviation (e.g., en) will be set to the session state. The reason for this elaborate way of doing things is that I need both the language code and full language name. Perhaps this is not the way to do this?
selected_full_src_lang = REV_MODEL_MAP[st.session_state["src_lang"]]
selected_src_lang = src_col.selectbox("Source language", tuple(MODEL_MAP.keys()),
index=list(MODEL_MAP.keys()).index(selected_full_src_lang))
st.session_state["src_lang"] = MODEL_MAP[selected_src_lang]Expected behavior:
When I click on an item in the dropdown, that that item is selected.
Actual behavior:
The item is briefly selected (milliseconds) but then the previous item is selected again instead.
Is this a regression?
No. It also occurs in 1.2.
Debug info
- Streamlit version: 1.10.0
- Python version: 3.8.8
- pipenv locally, something else on the demo page I guess
- OS version: Windows locally, and presumably Ubuntu online
- Browser version: tested on both Firefox and Edge (Chromium). Not a browser issues I think.