Use key as main identity for st.camera_input widget#12781
Merged
lukasmasuch merged 5 commits intodevelopfrom Nov 6, 2025
Merged
Use key as main identity for st.camera_input widget#12781lukasmasuch merged 5 commits intodevelopfrom
key as main identity for st.camera_input widget#12781lukasmasuch merged 5 commits intodevelopfrom
Conversation
Contributor
✅ 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. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the st.camera_input widget to use the key parameter as the main identity when provided, allowing for dynamic parameter changes without recreating the widget in the frontend.
- Changed
key_as_main_identityfromFalsetoTruein the camera input implementation - Added comprehensive unit tests to verify stable widget ID behavior when using keys
- Added end-to-end tests to validate dynamic property updates while maintaining widget state
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/streamlit/elements/widgets/camera_input.py | Updated key_as_main_identity parameter to True for stable widget identity |
| lib/tests/streamlit/elements/camera_input_test.py | Added unit test to verify widget ID stability with custom keys |
| e2e_playwright/st_camera_input_test.py | Added e2e test for dynamic property updates and updated widget count constants |
| e2e_playwright/st_camera_input.py | Added test case with dynamic camera input properties controlled by toggle |
Contributor
✅ PR preview is ready!
|
key as main identity for st.camera_input widgetkey as main identity for st.camera_input widget
…ity-for-camera-input
key as main identity for st.camera_input widgetkey as main identity for st.camera_input widget
sfc-gh-bnisco
approved these changes
Nov 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
If a custom
keyis passed to ast.camera_inputwidget 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
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Note
Use the widget
keyas the main identity forst.camera_input, and add unit/E2E tests (including a dynamic props scenario) to verify stable IDs and behavior.keyas main identity by settingkey_as_main_identity=Trueinlib/streamlit/elements/widgets/camera_input.py.test_stable_id_with_keyensuring the widget ID remains stable across rerenders with the samekey.st.camera_inputcontrolled by a toggle to changelabel,help, andwidthwhile preserving state (e2e_playwright/st_camera_input.py).NUM_CAMERA_INPUT_WIDGETS=5and update counts; addtest_dynamic_camera_input_propsvalidating label/help updates, width, and preserved value; import/utilize helpersclick_toggle,expect_help_tooltip,expect_prefixed_markdown.Written by Cursor Bugbot for commit df67f0d. This will update automatically on new commits. Configure here.