Skip to content

[fix] Remove erroneous expander block ID and align on_change defaults#14195

Merged
sfc-gh-lwilby merged 2 commits intodevelopfrom
fix/layout-on-change-default-and-expander-block-id
Mar 3, 2026
Merged

[fix] Remove erroneous expander block ID and align on_change defaults#14195
sfc-gh-lwilby merged 2 commits intodevelopfrom
fix/layout-on-change-default-and-expander-block-id

Conversation

@sfc-gh-lwilby
Copy link
Copy Markdown
Collaborator

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

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.

@sfc-gh-lwilby sfc-gh-lwilby added impact:internal PR changes only affect internal code change:bugfix PR contains bug fix implementation labels Mar 3, 2026
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Mar 3, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-14195/streamlit-1.54.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-14195.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-lwilby sfc-gh-lwilby marked this pull request as ready for review March 3, 2026 14:08
Copilot AI review requested due to automatic review settings March 3, 2026 14:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.id assignment so the element ID lives only in add_block.expandable.id.
  • Change st.tabs on_change default from None to "ignore" and disallow None as an input value.
  • Update unit tests to reflect the corrected ID behavior and the new on_change=None error 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]>
@lukasmasuch
Copy link
Copy Markdown
Collaborator

lukasmasuch commented Mar 3, 2026

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

Is this already adding the key as css class without the block_proto.id? This might be something to look into adding back in the context of: #14182 block_proto.id for stable container identity and class name, and the expander_proto.id for enabling widget-behaviour (similar to dialog).

Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@sfc-gh-lwilby sfc-gh-lwilby merged commit d2bea41 into develop Mar 3, 2026
43 checks passed
@sfc-gh-lwilby sfc-gh-lwilby deleted the fix/layout-on-change-default-and-expander-block-id branch March 3, 2026 18:21
github-actions bot pushed a commit that referenced this pull request Mar 3, 2026
…#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]>
GorML pushed a commit to GorML/streamlit that referenced this pull request Mar 8, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:internal PR changes only affect internal code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants