Skip to content

Fix issue with typing formatted values into st.number_input#12351

Merged
lukasmasuch merged 3 commits intodevelopfrom
fix/number-input-formatted-value-issue
Aug 28, 2025
Merged

Fix issue with typing formatted values into st.number_input#12351
lukasmasuch merged 3 commits intodevelopfrom
fix/number-input-formatted-value-issue

Conversation

@lukasmasuch
Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch commented Aug 27, 2025

Describe your changes

Fix a regression that makes it very hard to type in decimal numbers into st.number_input.

GitHub Issue Link (if applicable)

Testing Plan

  • Added e2e test that uses type and a decimal number.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Aug 27, 2025

🎉 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)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 27, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12351/streamlit-1.48.1-py3-none-any.whl
🕹️ Preview app pr-12351.streamlit.app (☁️ Deploy here if not accessible)

@lukasmasuch lukasmasuch added security-assessment-completed change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Aug 27, 2025
@sfc-gh-lmasuch sfc-gh-lmasuch marked this pull request as ready for review August 27, 2025 19:27
@sfc-gh-lmasuch sfc-gh-lmasuch requested a review from Copilot August 27, 2025 19:28
Copy link
Copy Markdown
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 PR fixes a regression in the st.number_input component where typing decimal values was problematic due to immediate formatting overriding user input. The fix ensures that while the input field is focused, raw user input is displayed instead of the formatted value, preventing keystrokes from being overridden.

Key changes:

  • Modified the display logic to show unformatted values during user input
  • Added comprehensive e2e test coverage for decimal input via keyboard

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
frontend/lib/src/components/widgets/NumberInput/NumberInput.tsx Introduces displayValue logic to bypass formatting during focus, preventing input interference
e2e_playwright/st_number_input_test.py Adds e2e test to verify decimal input functionality works correctly

)


def test_number_input_typing_decimal_via_keyboard(app: Page):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

question: Just to double-check, this test would have failed before this fix, correct?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, I tested it manually -> it would have failed in the current state.

@lukasmasuch lukasmasuch merged commit bd90424 into develop Aug 28, 2025
37 checks passed
@lukasmasuch lukasmasuch deleted the fix/number-input-formatted-value-issue branch August 28, 2025 10:06
lukasmasuch added a commit that referenced this pull request Aug 29, 2025
## Describe your changes

Fix a regression that makes it very hard to type in decimal numbers into
`st.number_input`.

## GitHub Issue Link (if applicable)

- Closes #12349

## Testing Plan

- Added e2e test that uses type and a decimal number. 

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
lukasmasuch added a commit that referenced this pull request Sep 17, 2025
## Describe your changes

Manually reverts the logic from these two changes to prevent some
unexpected issues with NumberInput usage:

- #12351
- #11885

## GitHub Issue Link (if applicable)

- Closes #12526
- Maybe related to #12465

## Testing Plan

- Added e2e test for one of the regression, the rest should be covered
well with the existing 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.

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

number_input not accepting keyboard input correctly

3 participants