question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass userTyping to custom formatter of InputNumber

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

Since the recent rewrite of InputNumber, which basically ignores the precision prop when there is a custom formatter, it is important to allow such custom formatter to fully replicate the precision logic. This requires that userTyping is passed down to said custom formatter. Whilst migrating to a new version of ant-design, one of my tests is breaking due to this change, and I cannot see any easy solution around it (apart from this feature request).

Reproduction: codesandbox

The reproduction very simply tries to imitate the precision prop functionality with a custom formatter. The moment a user types a value, the input automatically adds the precision and moves the cursor, making the input unusable. The custom formatter would need userTyping to prevent that from happening (+ some other situations).

What does the proposed API look like?

Pass userTyping to any custom formatter of the InputNumber component.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
shaodahongcommented, May 19, 2021

I like formatter(text: string, info: { userTyping: boolean }).

0reactions
xrkffggcommented, May 19, 2021

1

Read more comments on GitHub >

github_iconTop Results From Across the Web

regex InputNumber formatter ant-design - Stack Overflow
My solution: // formatter and parser input number export const formatterNumber = (val) => { if (!val) return 0; return `${val}`.replace(/\B( ...
Read more >
InputNumber - Ant Design
Enter a number within certain range with the mouse or keyboard.
Read more >
How to Use Formatted Text Fields
The easiest way to associate a customized format with a formatted text field is to create the field by using the JFormattedTextField constructor...
Read more >
type - Cypress Documentation
Text passed to .type() may include any of the special character sequences below. ... <input type="date"> ) requires specifying a valid date in...
Read more >
InputNumber - PrimeVUE - PrimeFaces
Component always provides a number type although formatting on the input is a ... InputNumber passes any valid attribute to the underlying input...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found