Skip to content

st.tabs & st.expander - Improve handling of frontend state/mount #8239

@mayagbarnes

Description

@mayagbarnes

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 or st.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 implementation, but it can be improved.

When we refactor st.tabs, we should also examine the heuristic we used to assess the selected tab:

When the number or names of the tabs change, we're now looking for the name of the active tab in the list of new tabs, and activating that one. This has the advantage that you can insert tabs and still keep the current tab active. But it comes at the cost of tabs switching when you simply rename them

Additional Context

See related issues:

More expansive feature request for FE/BE communication of tab state:

Metadata

Metadata

Assignees

Labels

feature:st.expanderRelated to the `st.expander` containerfeature:st.tabsRelated to the `st.tabs` containertype:enhancementRequests for feature enhancements or new features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions