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

handleChange bug for empty number values: parseFloat('') is null #258

Closed
cloud-walker opened this issue Nov 16, 2017 · 5 comments
Closed

Comments

@cloud-walker
Copy link

Input type number will be cast to null when cleared, because of this:

? parseFloat(value)

Demo with the latest version of formik: https://codesandbox.io/s/m7268r7xoy

@cloud-walker cloud-walker changed the title parseFloat('') is null handleChange bug for empty number values: parseFloat('') is null Nov 17, 2017
@cloud-walker cloud-walker changed the title handleChange bug for empty number values: parseFloat('') is null handleChange bug for empty number values: parseFloat('') is null Nov 17, 2017
@jaredpalmer
Copy link
Owner

True true.

@jaredpalmer
Copy link
Owner

Should this be parseFloat(val) !== null ? parseFloat(val) : ''?

@drew-dulgar
Copy link

drew-dulgar commented Dec 30, 2017

Related issue: #284

Also, for checking the value, what about this?

Number.isNaN(Number.parseFloat(val)) ? '' : Number.parseFloat(val);

@jaredpalmer
Copy link
Owner

Submit a PR and with this change and a test if you get a chance

@victordidenko
Copy link
Contributor

Didn't make test though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants