Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Jan 6, 2026

Describe your changes

Allow dynamically changing the min_value, max_value and step of st.number_input without 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

  • Added e2e and unit 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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

✅ PR preview is ready!

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

@snyk-io
Copy link
Contributor

snyk-io bot commented Jan 6, 2026

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

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0000%

  • Current PR: 86.5400% (12789 lines, 1721 missed)
  • Latest develop: 86.5400% (12789 lines, 1721 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@lukasmasuch lukasmasuch marked this pull request as ready for review January 6, 2026 01:05
Copilot AI review requested due to automatic review settings January 6, 2026 01:05
Copy link
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 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)

@lukasmasuch
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

@lukasmasuch lukasmasuch merged commit aa2b740 into develop Jan 7, 2026
44 checks passed
@lukasmasuch lukasmasuch deleted the feature/unlock-min-max-step-for-number-input branch January 7, 2026 21:30
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 security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants