Skip to content

Use key as main identity for st.feedback and st.pills widgets#12717

Merged
lukasmasuch merged 22 commits intodevelopfrom
stable-key-identity-for-feedback-pills
Oct 15, 2025
Merged

Use key as main identity for st.feedback and st.pills widgets#12717
lukasmasuch merged 22 commits intodevelopfrom
stable-key-identity-for-feedback-pills

Conversation

@lukasmasuch
Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch commented Oct 8, 2025

Describe your changes

If a custom key is passed to a st.pills or st.feedback widget it will be used as the main identity. This allows for dynamically changing other parameters in between reruns without causing the widgets to be recreated in the frontend.

GitHub Issue Link (if applicable)

Testing Plan

  • Added unit and e2e tests.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Oct 8, 2025

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

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 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 Oct 8, 2025

✅ PR preview is ready!

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

@lukasmasuch lukasmasuch requested a review from Copilot October 8, 2025 08:56
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

This PR updates the identity mechanism for st.feedback and st.pills widgets to use the key parameter as the main identity, similar to how st.segmented_control already works. This allows these widgets to maintain their state when other non-whitelisted parameters change, while still generating new IDs when whitelisted parameters (like options or click_mode) change.

  • Extended key-based identity behavior from segmented_control to feedback and pills widgets
  • Added comprehensive test coverage for the new identity behavior
  • Added E2E tests to verify dynamic property updates preserve widget state

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/streamlit/elements/widgets/button_group.py Updated to use key as main identity for all button group widgets (feedback, pills, segmented_control)
lib/tests/streamlit/elements/button_group_test.py Added unit tests for stable ID behavior with key for feedback and pills widgets
e2e_playwright/st_feedback.py Added E2E test app with dynamic feedback widget to test state preservation
e2e_playwright/st_feedback_test.py Added E2E test to verify feedback widget state is preserved during prop updates
e2e_playwright/st_pills.py Added E2E test app with dynamic pills widget to test state preservation
e2e_playwright/st_pills_test.py Added E2E test to verify pills widget state is preserved during prop updates

@lukasmasuch lukasmasuch added security-assessment-completed change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Oct 8, 2025
Base automatically changed from stable-key-identity-for-segmented-control to develop October 8, 2025 16:42
@lukasmasuch lukasmasuch marked this pull request as ready for review October 13, 2025 17:12
@lukasmasuch lukasmasuch requested a review from Copilot October 13, 2025 17:13
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

Copilot reviewed 6 out of 18 changed files in this pull request and generated 1 comment.

@lukasmasuch lukasmasuch merged commit a4d17f5 into develop Oct 15, 2025
39 checks passed
@lukasmasuch lukasmasuch deleted the stable-key-identity-for-feedback-pills branch October 15, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants