primitives
primitives copied to clipboard
[Menu, DropdownMenu] Allow CheckboxItem state to be indeterminate
Description
Addresses #1581 — allows the Menu.CheckboxItem
/DropdownMenu.CheckboxItem
to have an indeterminate state (and aria-checked='mixed'
attribute). Implementation was largely referenced from the core Checkbox primitive, where this was already available.
Some notes:
- I'm extremely late to learning Typescript in my career, so please let me know if there are any cleanups/improvements that could be made in that respect (or any other respect, of course)
- I exported
isIndeterminate
,getState
, and theCheckboxState
type from the Checkbox package instead of recreating these forMenuCheckboxItem
— I'm not sure if this change warrants aminor
release, but I figured all the affected packages should get the same bump. Let me know if this is incorrect? - ContextMenu was flagged for an update only because I needed to add type arguments to the
useState
calls in the Checkbox Item story — again, not sure if this should warrant a release or not?
I've tested my changes via updated stories for Menu and DropdownMenu ('Checkbox Items' in both).
Happy to make any changes as necessary!
just my two cents... i'm not sure it makes much sense to create a dependency between @radix-ui/react-checkbox
and @radix-ui/react-menu
here given that the menu never renders the checkbox component.
personally i'd copy/paste the type and utils you're re-using here, they're very small.
@jjenzz I wondered about that as well. I thought syncing up these up might help to prevent breaking this feature parity in the future, but if the cost of creating the dependency outweighs that risk, I'm of course happy to change it!
I agree with Jenna, let's duplicate the bits mentioned rather than add a dependency.
@jjenzz @benoitgrelard Done! Please let me know if you see any other changes/improvements to be made. (Also, even after running the version check after these changes, it seems the Checkbox component is still marked for an update, even though it's now unchanged compared to the main branch. Not quite sure how to roll that back as it doesn't appear in the release options now, any ideas?)
Not quite sure how to roll that back as it doesn't appear in the release options now, any ideas?)
You can delete the version file and re-run the command.
Thank you, done!
@jjenzz @benoitgrelard Just checking in — any other changes you'd like to see, or do you reckon this can proceed to workflows & merging? Thanks!
@benoitgrelard Requested changes are in, let me know if you'd like any other updates!