-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing last number with trailing zeros deletes all the right side zeros, when integrating with react-hook-form
#835
Comments
UPDATE: it seems that removing these lines make it work as expected: https://github.com/s-yadav/react-number-format/blob/master/src/utils.tsx#L516-L528 |
Hey @pedroapfilho, the issue is that RNF currently works partially controlled and partially uncontrolled way. And in this case, when used floatValue on the state, Prior to v5 it used to work, because we were comparing floatValue coming from prop and floatValue inside the state, if that not changed we were not rendering the input. But that had some other bugs. To unblock yourself, I would suggest that for state management use a numeric string value and on submit convert it to a number, Or you can have a custom component which manages the string state and passes the numeric value to parent. |
Doing it this way introduces some other bugs, in the end it was flaky, and didn't pass the tests that were created to prior. It would be nice to have it fixecd on v6. I'm willing to sponsor the project to make it happen. |
Describe the issue and the actual behavior
Currently, while integrating a
NumberFormatBase
withuseNumericFormat
, and usingreact-number-format
, there's one edge case where we need the value to be a number, and when we type something like10.10001
and thenbackspace
, it goes to10.1
, and not to10.000
, as expected.Screen.Recording.2024-04-10.at.10.08.44.mov
Provide a CodeSandbox link illustrating the issue
https://codesandbox.io/p/sandbox/flamboyant-poitras-c7nkld?file=%2Fsrc%2FApp.js%3A24%2C1
Provide steps to reproduce this issue
Type backspace on the input
Please check the browsers where the issue is seen
The text was updated successfully, but these errors were encountered: