If no initial value is defined for `Checkbox` it does not behaves as expected
KOliver94 opened this issue · comments
Current Behavior 😯
When a Checkbox
does not have a value and in an indeterminate state it changes its value to ["on"]
rather than true
or false
for the first click then for a second click it stays selected but with value []
and you cannot change that with more clicks. If I reset the form after the second click it changes its bahavior and works as expected but the reset only solves this after the second click.
Expected Behavior 🤔
After the indeterminate state it should either be true
or false
for the clicks. It worked like that with MUI v4.
Steps to Reproduce 🕹
Define a Checkbox
without setting its value. See the following codesandbox.
The initial value is required. Without it you will be switching from a uncontrolled to controlled component hence the warning in your codesandbox console
Secondly Formik has special handling for checkboxes
The best we can do in this case if warn the user if we get an undefined value