-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
st.tabs
& st.expander
- Improve handling of frontend state/mount
#8239
Labels
feature:st.expander
feature:st.tabs
type:enhancement
Requests for feature enhancements or new features
Comments
mayagbarnes
added
type:enhancement
Requests for feature enhancements or new features
feature:st.tabs
labels
Mar 5, 2024
This was referenced Mar 5, 2024
mayagbarnes
changed the title
Mar 5, 2024
st.tabs
- Improve handling of frontend state/mountst.tabs
& st.expander
- Improve handling of frontend state/mount
Hi Team, I seem to have this same issue but it happens when I have this sort of a code pattern: # This doesn't work and tabs get reset on button click
(
tab1,
tab2,
) = st.tabs([
"Tab 1",
"Tab 2",
])
def handle_on_click() -> None:
if st.session_state.some_state:
_ = update_records_in_db()
with tab1:
clicked = st.button("Update Records", on_click=handle_on_click)
if clicked:
st.success("Records Updated!", icon="👍🏻")
with tab2:
# some other code
pass The workaround I found for this particular issue is to modify the code like so: # This works as expected
(
tab1,
tab2,
) = st.tabs([
"Tab 1",
"Tab 2",
])
with tab1:
st.button("Update Records", key="my_button_key")
if st.session_state.my_button_key:
updated = update_records_in_db()
st.success(f"`{updated}` records updated!", icon="👍🏻")
with tab2:
# some other code
pass |
+1 Having same issues |
Please fix this |
Hi @mayagbarnes Is this going to be fixed in |
I still have drop downs in my tab 2 that when clicked cause the tabs to reset back to tab 1. Is this in the priority list? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature:st.expander
feature:st.tabs
type:enhancement
Requests for feature enhancements or new features
Summary
Improve the management/heuristics used to handle rendering the frontend
st.tabs
&st.expander
React components.Scenarios such as conditionally rendering elements before
st.tabs
orst.expander
causes the unmount/remount of the component, therefore losing its FE state/selected tab. This is expected behavior based on the components in their current form, but it can be improved.When we refactor
st.tabs
, we should also examine the heuristic we used to assess the selected tab:Additional Context
See related issues:
More expansive feature request for FE/BE communication of tab state:
More expansive feature request for FE/BE communication of expander state:
The text was updated successfully, but these errors were encountered: