[fix] Remove erroneous expander block ID and align on_change defaults#14195
Conversation
Made-with: Cursor Co-authored-by: lawilby <[email protected]>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull request overview
Fixes layout container state persistence by correcting where element IDs are stored for st.expander and standardizing on_change defaults for stateful layout containers.
Changes:
- Remove expander
add_block.idassignment so the element ID lives only inadd_block.expandable.id. - Change
st.tabson_changedefault fromNoneto"ignore"and disallowNoneas an input value. - Update unit tests to reflect the corrected ID behavior and the new
on_change=Noneerror behavior for tabs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/streamlit/elements/layouts.py |
Align tabs(on_change) default to "ignore", tighten validation, and stop setting block-level IDs for expanders. |
lib/tests/streamlit/elements/layouts_test.py |
Update expander ID assertions and change the tabs test to expect an exception for on_change=None. |
Made-with: Cursor Co-authored-by: lawilby <[email protected]>
Is this already adding the |
…#14195) ## Describe your changes Fixes two issues in layout container state persistence: - Removes erroneous `block_proto.id = element_id` assignment in `st.expander` — the ID should only live on `expandable_proto.id`, matching the pattern used by `st.tabs` and `st.popover` - Aligns `on_change` default to `"ignore"` across all three stateful layout containers. `st.tabs` previously used `None` as its default and accepted `None` as a value; now it uses `"ignore"` consistent with `st.expander`, `st.popover`, and the [product spec](../specs/2026-01-14-dynamic-tabs-expander/product-spec.md#new-parameter-on_change) ## GitHub Issue Link (if applicable) ## Testing Plan - Unit Tests (JS and/or Python) - Updated existing tests to match corrected behavior (block-level ID not set on expander, `on_change=None` now raises on tabs). **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: lawilby <[email protected]>
…streamlit#14195) Fixes two issues in layout container state persistence: - Removes erroneous `block_proto.id = element_id` assignment in `st.expander` — the ID should only live on `expandable_proto.id`, matching the pattern used by `st.tabs` and `st.popover` - Aligns `on_change` default to `"ignore"` across all three stateful layout containers. `st.tabs` previously used `None` as its default and accepted `None` as a value; now it uses `"ignore"` consistent with `st.expander`, `st.popover`, and the [product spec](../specs/2026-01-14-dynamic-tabs-expander/product-spec.md#new-parameter-on_change) - Unit Tests (JS and/or Python) - Updated existing tests to match corrected behavior (block-level ID not set on expander, `on_change=None` now raises on tabs). **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: lawilby <[email protected]>
Describe your changes
Fixes two issues in layout container state persistence:
block_proto.id = element_idassignment inst.expander— the ID should only live onexpandable_proto.id, matching the pattern used byst.tabsandst.popoveron_changedefault to"ignore"across all three stateful layout containers.st.tabspreviously usedNoneas its default and acceptedNoneas a value; now it uses"ignore"consistent withst.expander,st.popover, and the product specGitHub Issue Link (if applicable)
Testing Plan
on_change=Nonenow raises on tabs).Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.