Parse numeric strings as numbers (#902)
* Parse numeric strings as numbers * Additionally check for type of field value
This commit is contained in:
parent
b38a5e653c
commit
179a539d4d
@ -450,7 +450,9 @@ function InputInner ({
|
|||||||
if (draft) {
|
if (draft) {
|
||||||
// for some reason we have to turn off validation to get formik to
|
// for some reason we have to turn off validation to get formik to
|
||||||
// not assume this is invalid
|
// not assume this is invalid
|
||||||
helpers.setValue(draft, false)
|
const isNumeric = /^[0-9]+$/.test(draft)
|
||||||
|
const numericExpected = typeof field.value === 'number'
|
||||||
|
helpers.setValue(isNumeric && numericExpected ? parseInt(draft) : draft, false)
|
||||||
onChange && onChange(formik, { target: { value: draft } })
|
onChange && onChange(formik, { target: { value: draft } })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user