Use key as main identity for st.time_input & st.date_input#12464
Merged
lukasmasuch merged 13 commits intodevelopfrom Sep 10, 2025
Merged
Use key as main identity for st.time_input & st.date_input#12464lukasmasuch merged 13 commits intodevelopfrom
key as main identity for st.time_input & st.date_input#12464lukasmasuch merged 13 commits intodevelopfrom
Conversation
Contributor
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
Contributor
✅ PR preview is ready!
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements stable widget IDs for st.time_input and st.date_input when a custom key is provided, allowing dynamic parameter updates without recreating widgets in the frontend.
- Enables use of
keyas main identity for time and date input widgets - Adds whitelisting for parameters that affect widget state (
stepfor time_input,min_value/max_valuefor date_input) - Ensures widget state preservation across reruns when non-whitelisted parameters change
Reviewed Changes
Copilot reviewed 8 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/streamlit/elements/widgets/time_widgets.py | Updates time_input and date_input to use key as main identity with specific parameter whitelisting |
| lib/streamlit/elements/widgets/number_input.py | Adds clarifying comment about parameter whitelisting for number_input |
| lib/tests/streamlit/elements/time_input_test.py | Adds unit tests for stable ID behavior and whitelisted parameter changes |
| lib/tests/streamlit/elements/date_input_test.py | Adds unit tests for stable ID behavior in both single and range date modes |
| e2e_playwright/st_time_input_test.py | Adds e2e test for dynamic time input property updates |
| e2e_playwright/st_time_input.py | Implements test app with dynamic time input toggling |
| e2e_playwright/st_date_input_test.py | Adds e2e test for dynamic date input property updates |
| e2e_playwright/st_date_input.py | Implements test app with dynamic date input toggling |
4 tasks
sfc-gh-bnisco
approved these changes
Sep 9, 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 any of thest.time_inputandst.date_inputwidgets 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.