[DynamicContainers] Callback support for popovers#14075
[DynamicContainers] Callback support for popovers#14075sfc-gh-lwilby merged 1 commit intodevelopfrom
Conversation
✅ 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!
|
2869e33 to
8b76087
Compare
There was a problem hiding this comment.
Pull request overview
This pull request adds callback support to st.popover, extending its existing state management functionality to support user-defined callback functions in addition to the string literals "ignore" and "rerun". This brings popover in line with other Streamlit widgets that support callbacks (like st.checkbox, st.button, etc.).
Changes:
- Extended
st.popoverto accept callable functions as theon_changeparameter - Added
argsandkwargsparameters to pass arguments to callbacks - Updated validation logic to check for callable in addition to string literals
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/streamlit/elements/layouts.py |
Core implementation: Added WidgetCallback, WidgetArgs, WidgetKwargs imports; extended on_change parameter type to include callables; added args and kwargs parameters; updated validation, state tracking, and widget registration logic; enhanced documentation |
lib/tests/streamlit/elements/layouts_test.py |
Comprehensive unit tests covering callback behavior: state tracking, proto ID setting, metadata registration, callback firing on state changes, args/kwargs handling, session state accessibility, and error handling |
lib/tests/streamlit/typing/popover_container_types.py |
Type tests to verify correct type annotations for callable callbacks and parameter passing |
e2e_playwright/st_popover.py |
E2E test app with three callback scenarios: basic callback, callback with args/kwargs, and callback inside a fragment |
e2e_playwright/st_popover_test.py |
E2E tests verifying callback behavior in real app scenarios: callback firing on open/close, args/kwargs passing, and fragment integration; updated popover count from 18 to 21 |
Consolidated Code ReviewSummaryThis PR adds callable Files changed:
Reviewer AgreementBoth reviewers (
Code QualityThe implementation is well-structured and localized:
No blocking code quality issues were identified by either reviewer. Test CoverageCoverage is strong across all test layers:
Backwards CompatibilityNo breaking changes. Security & RiskNo security concerns. Regression risk is low and well-mitigated by the comprehensive test additions. AccessibilityNo frontend changes — no accessibility implications. Recommendations (Non-blocking)Both reviewers offered minor, non-blocking suggestions. Consolidated:
VerdictAPPROVED: Both reviewers approved. The change is well-scoped, backwards compatible, follows established widget callback patterns, and is thoroughly tested across unit, E2E, and typing test layers. All recommendations are non-blocking. Consolidated review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR adds callable Code QualityThe implementation is clean and localized:
No blocking code quality issues were identified. Test CoverageCoverage is strong for the changed behavior:
Overall, tests are adequate for merge. Backwards CompatibilityNo breaking change detected:
Security & RiskNo new security concerns identified. AccessibilityNo frontend component logic was changed. Accessibility impact is minimal and neutral for this PR. Recommendations
VerdictAPPROVED: The change is well-scoped, backwards compatible, and sufficiently tested for the new popover callback functionality. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR adds Files changed:
Code QualityThe implementation is clean and follows existing patterns well:
Minor style items:
Test CoverageTest coverage is strong: Unit tests (12 new tests):
E2E tests (3 new tests):
Typing tests:
One observation per E2E AGENTS.md guidance ("Prefer a single aggregated scenario test over many micro-tests when they share the same setup and page state"): Missing coverage (non-blocking): There is no test verifying that passing Backwards CompatibilityNo breaking changes. This is purely additive:
Security & RiskNo security concerns. Callbacks are user-provided functions that execute in the same Python process, consistent with how all other widget callbacks work. No new attack surface is introduced. The risk of regression is low:
AccessibilityNo frontend changes are included in this PR. The feature is entirely backend (Python callback plumbing), so there are no accessibility implications. Recommendations
VerdictAPPROVED: Clean, well-tested feature addition that extends This is an automated AI review by |
58da0c8 to
3f9da78
Compare
lib/streamlit/elements/layouts.py
Outdated
| if not callable(on_change) and (args is not None or kwargs is not None): | ||
| raise StreamlitAPIException( | ||
| "`args` and `kwargs` can only be used when `on_change` is a callable." | ||
| ) |
There was a problem hiding this comment.
Same as in the other PR, I think it's better not to throw this error (see other PR)
3f9da78 to
05417bb
Compare
Co-authored-by: lawilby <[email protected]>
05417bb to
7b662ec
Compare

Describe your changes
Adds
on_changecallback support tost.popover, consistent with the existing callback pattern in other widgets (st.checkbox,st.toggle, etc.).on_changeaccepts a callable in addition to the existing"ignore"/"rerun"string literalsargsandkwargsparameters pass through to the callbackst.session_state[key]inside the callback to distinguish between open (True) and close (False) events.GitHub Issue Link (if applicable)
Testing Plan
lib/tests/streamlit/elements/layouts_test.pye2e_playwright/st_popover_test.pyContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.