Closed dgutt17 closed 2 years ago
👍I've ended up using the same workaround before. This would be a nice bug to tackle.
@dgutt17 : I created a very small form to test this issue:
function TestCheckboxForm ({ handleSubmit, submitting }) {
return (
<form onSubmit={ handleSubmit } noValidate>
<Field
name="isCool"
component={Checkbox}
label="Are you cool?"
/>
<Field
name="name"
label="Name: "
component={Input}
/>
<SubmitButton submitting={submitting}>
Submit
</SubmitButton>
</form>
)
}
Using the Redux devtools and console logs, I always see the checkbox value be either true
or false
, regardless of blur events. When I looked more into the Github conversation you reference there were multiple issues related to the checkbox behvior being broken, in particular: https://github.com/redux-form/redux-form/pull/3482. Note though that this "fix" was done much earlier than your reported problem. I wonder if we were using an older version of redux-form when you reported this issue. The version of redux-form that was used to create this test (from the client template) is 8.3.1. Thoughts?
@mwislek Have you run into this on other projects using v8 of redux-form? If not, I think we can close this issue
@chawes13 . No. Dan never got back to me regarding my questions above. I agree to close.
I was using the Checkbox input from lp-components. When I clicked the Checkbox from false to true the value properly update the redux store to true. When I clicked the Checkbox from true to false the redux store updated to an empty string, which was not expected.
The blur event changed the false value to an empty string. Conor and I ended up coercing the empty strings value into a false value by doing this
normalize={(v) => !!v}
.This solution came from this issue in Github: https://github.com/erikras/redux-form-material-ui/issues/147. This is the same issue we were having with a form in the empower client.