-
Notifications
You must be signed in to change notification settings - Fork 409
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
Thousand and decimal formatting broken while typing when valueIsNumericString is set to false with react-final-form #741
Comments
Running into this as well, but without Here is the code that is doing that: react-number-format/src/utils.tsx Lines 430 to 439 in 11af4c5
Now you may be thinking typeof value === 'number' would be true , we are supplying a number. But it is always a string at this point (when getting the input's value to be displayed). It uses roundIncomingValueToPrecision as the value when passing it to useInternalValues and returns formattedValue which isn't formatted in this case.react-number-format/src/numeric_format.tsx Lines 376 to 383 in 11af4c5
Here is roundIncomingValueToPrecision and you can see if the value is a number, it will make it a stringreact-number-format/src/numeric_format.tsx Lines 358 to 374 in 11af4c5
Here is that formattedValue being returned as value . This returned value is later passed to NumberFormatBase react-number-format/src/numeric_format.tsx Lines 479 to 490 in 11af4c5
react-number-format/src/numeric_format.tsx Lines 493 to 499 in 11af4c5
NumberFormatBase actually runs useInternalValues again. This time is it with the value from that previous run that is already a string at this point.
Here is a sandbox without final form: Assuming what the above is correct, setting this to always be react-number-format/src/numeric_format.tsx Line 379 in 11af4c5
OR after rounding, convert it back to a number. The workaround (as mentioned in the original post) is to just set |
@TheSharpieOne thanks for digging on this. |
… valueIsNumericString is set to false
@s-yadav Confirming that this bug is occurring to me too. Do you have a rough estimate on when this fix will be available? |
This is fixed on v5.2.0 |
Describe the issue and the actual behavior
When using react-number-format with react-final-form where I need to store the floatValue, if I set the parameter valueIsNumericString to false even if I provide a numeric value to NumericFormat, the formatting of the input text is not done while typing.
If I remove valueIsNumericString or if I set it to true (even with numeric value) or undefined, it works.
Describe the expected behavior
I would like the decimal and thousand formatting to work while typing.
Provide a CodeSandbox link illustrating the issue
https://codesandbox.io/embed/react-final-form-w-react-number-format-forked-7byc8q?fontsize=14&hidenavigation=1&theme=dark
Provide steps to reproduce this issue
Start writing anything in the input (adding 0 for example), no formatting will occur
The text was updated successfully, but these errors were encountered: