next(breaking): change checked
type for checkbox components
#898
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having the
checked
state beboolean | 'indeterminate'
is quite annoying, especially considering from a user's perspective, once you leave the'indeterminate'
state, you can't toggle back to it.This PR changes the
checked
props to beboolean
and adds anindeterminate
prop which is also of typeboolean
.If you wish to have a checkbox in an indeterminate state, you can simply do the following:
By default, when a user clicks an
indeterminate
checkbox, it will changechecked
totrue
andindeterminate
tofalse
.indeterminate
can be controlled, so you can programmatically put a checkbox back into the indeterminate state if you wish, using the normal state management strategies (bind:indeterminate
,onIndeterminateChange
,controlledIndeterminate
).I've wanted to make this change for some time and many others have expressed frustration with always having to conditionally check the type when working with things that expect a
boolean
.Additionally, the snippet props for the
Checkbox
and*Menu.CheckboxItem
components have been adjusted to expose both achecked
andindeterminate
prop:Closes #885