Skip to content

fix(module:input-number): make sure the displayed value is correct - #9312

Merged
Laffery merged 1 commit into
NG-ZORRO:masterfrom
HyperLife1119:fix/number-display-value
Aug 6, 2025
Merged

Laffery merged 1 commit into
NG-ZORRO:masterfrom
HyperLife1119:fix/number-display-value

Conversation

@HyperLife1119

Copy link
Copy Markdown
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Application (the showcase website) / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #9309

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@codecov

codecov Bot commented Aug 6, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.12%. Comparing base (d3bc0ee) to head (228a2ae).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9312   +/-   ##
=======================================
  Coverage   92.12%   92.12%           
=======================================
  Files         561      561           
  Lines       19627    19631    +4     
  Branches     3106     3107    +1     
=======================================
+ Hits        18082    18086    +4     
  Misses       1206     1206           
  Partials      339      339           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


function defaultParser(value: string): number {
return parseFloat(value.trim().replace(/,/g, '').replace(/。/g, '.'));
const parsedValue = value.trim().replace(/,/g, '').replace(/。/g, '.');

@HyperLife1119 HyperLife1119 Aug 6, 2025 •

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.

关键修复:在输入 1abc 这样的值时,输入前的显示值为 1,输入结束后又经过 parseFloat 将 1abc 格式化为了正确的值 1,导致输入前和输入后的值是一样的,angular 会忽略这个渲染更新。

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 bug in the input-number component to ensure the displayed value is correct during user input. The fix addresses an issue where the display value wasn't properly updated when users typed invalid characters or incomplete numbers.

  • Moves the display value update to occur immediately when typing begins
  • Conditionally applies formatting only when a formatter is provided during typing
  • Improves the default parser to handle empty strings correctly

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
components/input-number/input-number.component.ts Updates display value logic and improves default parser for empty strings
components/input-number/input-number.component.spec.ts Adds test case for invalid input handling
components/input-number/demo/formatter.ts Updates parser functions to use unary plus operator instead of parseFloat

@NG-ZORRO NG-ZORRO deleted a comment from Copilot AI Aug 6, 2025
@NG-ZORRO NG-ZORRO deleted a comment from Copilot AI Aug 6, 2025
@HyperLife1119 HyperLife1119 linked an issue Aug 6, 2025 that may be closed by this pull request
@Nicoss54
Nicoss54 self-requested a review August 6, 2025 07:55

@Nicoss54 Nicoss54 left a comment

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.

LGTM

@Laffery Laffery left a comment

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.

LGTM

@Laffery
Laffery merged commit 7a2d3b6 into NG-ZORRO:master Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inputNumber

4 participants