Allow dynamically changing in min, max and step in st.number_input#13512
Merged
lukasmasuch merged 5 commits intodevelopfrom Jan 7, 2026
Merged
Allow dynamically changing in min, max and step in st.number_input#13512lukasmasuch merged 5 commits intodevelopfrom
st.number_input#13512lukasmasuch merged 5 commits intodevelopfrom
Conversation
Contributor
✅ PR preview is ready!
|
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
📉 Frontend coverage change detectedThe frontend unit test (vitest) coverage has decreased by 0.0000%
✅ Coverage change is within normal range. |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request allows st.number_input to dynamically change min_value, max_value, and step parameters without triggering a widget identity change or state reset. When the current value becomes invalid due to bound changes, it automatically resets to the default value, providing behavior consistent with other Streamlit widgets like st.selectbox.
Key changes:
- Widget ID stability now applies to all parameters when a key is provided, not just a whitelisted subset
- Out-of-range values are automatically reset to the default instead of raising exceptions
- Session state is properly updated when value resets to avoid inconsistencies
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
lib/streamlit/elements/widgets/number_input.py |
Changed key_as_main_identity from a whitelist set to True for full parameter stability, and replaced exception-throwing with automatic value reset when bounds change |
lib/tests/streamlit/elements/number_input_test.py |
Removed unused StreamlitValueBelowMinError import, updated test to expect reset behavior instead of exceptions, removed whitelisted parameter tests, and added comprehensive tests for dynamic bound changes |
e2e_playwright/st_number_input.py |
Updated test app to actually change min/max/step values dynamically to demonstrate the new capability |
e2e_playwright/st_number_input_test.py |
Enhanced test to verify both value preservation when still valid and value reset when invalid after bound changes |
e2e_playwright/__snapshots__/linux/st_number_input_test/st_number_input-dynamic_updated[webkit].png |
Updated screenshot reflecting the new dynamic bounds (step changes from 1 to 5) |
e2e_playwright/__snapshots__/linux/st_number_input_test/st_number_input-dynamic_updated[chromium].png |
Updated screenshot reflecting the new dynamic bounds (step changes from 1 to 5) |
…in-max-step-for-number-input
Collaborator
Author
|
@cursor review |
sfc-gh-bnisco
approved these changes
Jan 7, 2026
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
Allow dynamically changing the
min_value,max_valueandstepofst.number_inputwithout triggering an identity change / state reset. If the current selected options isn't in the list of available option, it will be reset to the default value.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.