Leading numbers trimmed when using type for decimals in numeric input
See original GitHub issue@testing-library/user-event
version:12.0.2
- Testing Framework and version:
jest 26.0.1
- DOM Environment:
jsdom 16.2.2
What you did:
Testing floating point values entered asynchronously into numeric text using type
. I had mentioned this at the end of #336, and finally got around to testing it today. I’ve updated the sandbox dependencies. I’ve also updated the tests to reflect the new API changes.
What happened: The leading numbers (before decimal point) are getting trimmed off in my tests.
Reproduction sandbox: https://codesandbox.io/s/user-event-decimals-trimmed-hf0wx
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to handle floats and decimal separators with html5 input ...
Input type =number · User enters "4,55" to input field · $("#my_input").val(); returns "4,55" · Thats fine, I can replace comma with dot...
Read more >How to: Pad a Number with Leading Zeros | Microsoft Learn
To pad an integer with leading zeros to a specific length ... Determine whether you want to display the integer as a decimal...
Read more >decimal — Decimal fixed point and floating point arithmetic ...
Decimal floating point objects share many properties with the other built-in numeric types such as float and int . All of the usual...
Read more >LEADINGZEROS( ) function - HighBond
Leading and trailing spaces are automatically trimmed from character values, and from the result of character expressions, before the leading zeros are added....
Read more >Article: Number Formatting - Boomi Community
Numbers after the decimal will be truncated unless it is explicitly defined but numbers before the decimal will be preserved whether you defined ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re getting issues because
3.
is an invalid value in a number input so you can’t programmatically set that value. This is why we have the complex logic we do in the type utility.Also, the value is set programmatically in the fireEvent utility in DOM Testing Library. Which is why you can’t do it by dispatching an event. I suggest diving into the code a bit. I’m on my phone, but you should be able to find it.
Please do! 😃