Closed renato-bohler closed 5 years ago
This returns an empty string for the normalize function if allowEmpty
is set. The API docs say that if allowEmpty
is set then undefined
will stored. Could this be part of the issue?
@mitchvoll redux-form
's change
action will not set the Field
value to undefined
if its payload
is undefined
(in fact it will do nothing if that's the case). One way to set undefined
to the Field
with this action is to set the payload to an empty string, but that only works if the target Field
has no initial values - and that's the cause of this issue.
There's more information here: https://github.com/erikras/redux-form/issues/3946#issuecomment-388550168.
I think the only way to really solve this for the current version of redux-form
is to set the value to null
instead of undefined
(the change
action will set to null
if the payload is null
), but that will cause a breaking change.
:tada: This issue has been resolved in version 2.0.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
What are you reporting?
What is the current behavior?
When a
Field
which has an initial value is using a number mask with theallowEmpty
option set, it is not possible to set the input value to zero. Also, in this case, instead of setting theField
's value toundefined
, it sets to an empty string.What is the expected behavior?
We should be able to set the
Field
to0
in this case and the value when the input is empty should beundefined
ornull
.Sandbox Link
https://codesandbox.io/s/n4k073xzj
What's your environment?
Other information
This is related to https://github.com/erikras/redux-form/issues/3946. The only viable way to fix it is changing may be changing the
normalize
's return tonull
forallowEmpty
(which makes more sense to me), but this may be a breaking change.