Skip to content
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

String formatting with decimals <= "0.00000001" are converting wrong #506

Closed
briancorbin opened this issue Mar 25, 2021 · 2 comments · Fixed by #522
Closed

String formatting with decimals <= "0.00000001" are converting wrong #506

briancorbin opened this issue Mar 25, 2021 · 2 comments · Fixed by #522

Comments

@briancorbin
Copy link

briancorbin commented Mar 25, 2021

Describe the issue and the actual behavior

When formatting a string <= "0.0000001", it's converting it into

This is a new issue as of 4.5.0, and the current latest working version without this bug I have found is 4.4.4

Describe the expected behavior

It should be converting this into 1e-7, not 1e7

Provide a CodeSandbox link illustrating the issue

https://codesandbox.io/s/ppo1kvlwpx?file=/index.js

Provide steps to reproduce this issue

type "0.0000001" into the formik field that says "Simple Input Works" and it will turn "0.0000001" into 1e7 and then if you click away it will turn in to 17 in the fields below.

@nikhil-varma
Copy link
Collaborator

Hey @briancorbin ! Thanks for reporting this issue. We will investigate and pick this up to provide a resolution soon. Keep an eye out for updates!

@s-yadav
Copy link
Owner

s-yadav commented Apr 6, 2021

Hey @briancorbin, I think the real root cause is that the NumberFormat does not support exponential numbers as value prop. So one solution is to use and pass value, or formattedValue from the values object.

The issue was not visible on 4.4.8 as we were converting it to fixed value, so basically it was removing the decimal part of it.
And it got visible by the change we introduced on the v4.5.0 (0619c04#diff-3274f1a37032fb0ae4e2823def0007c634e869ae0dfc304ff6a12c36513c3a52R93)

We will look into supporting exponential numbers as a separate tasks. But meanwhile don't use the floatValues to pass it back as value prop.

cc @nikhil-varma

s-yadav added a commit that referenced this issue Apr 10, 2021
@s-yadav s-yadav mentioned this issue Apr 10, 2021
6 tasks
s-yadav added a commit that referenced this issue Apr 10, 2021
s-yadav added a commit that referenced this issue Apr 10, 2021
s-yadav added a commit that referenced this issue Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants