-
Notifications
You must be signed in to change notification settings - Fork 632
Description
Summary
If you create a checkbox and set its value param to a session_state value then use a button with a callback on its on_click param and update that session_state value, after the rerun the checkbox does not get updated despite the value being EXPLICITLY True or False.
Steps to reproduce
Code snippet:
def select_all(index):
st.session_state[f"test"] = True
def update_checkbox():
st.session_state["test"] = not st.session_state["test"]
if "test" not in st.session_state.keys():
st.session_state["test"] = False
index = 1
print(f"VALUE: {st.session_state["test"]}")
st.checkbox(
label=f"{index}",
value=st.session_state["test"],
key=f"checkbox_{index}",
on_change=update_checkbox,
)
st.button(
label="test2",
on_click=select_all,
args=[index]
)
Screenshot(s):
If applicable, please provide the steps we should take to reproduce the bug:
just create a local web app with test.py as a page in app.py
Expected behavior:
When the button is clicked the checkbox should reflect the value being explicitly set in the value param
Actual behavior:
Does not update the checkbox, (the value is actually being updated, its just not being rerendered.)
Is this a regression?
That is, did this use to work the way you expected in the past?
yes, this was never an issue.
Debug info
Streamlit, version 1.51.0
- OS version: Windows 11
- Browser version: Google Chrome Version 141.0.7390.123