primitives icon indicating copy to clipboard operation
primitives copied to clipboard

[Menu, DropdownMenu] Allow CheckboxItem state to be indeterminate

Open colepeters opened this issue 2 years ago • 7 comments

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 the CheckboxState type from the Checkbox package instead of recreating these for MenuCheckboxItem — I'm not sure if this change warrants a minor 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!

colepeters avatar Aug 17 '22 21:08 colepeters

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 avatar Aug 19 '22 09:08 jjenzz

@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!

colepeters avatar Aug 19 '22 16:08 colepeters

I agree with Jenna, let's duplicate the bits mentioned rather than add a dependency.

benoitgrelard avatar Aug 23 '22 15:08 benoitgrelard

@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?)

colepeters avatar Aug 23 '22 18:08 colepeters

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.

benoitgrelard avatar Aug 23 '22 21:08 benoitgrelard

Thank you, done!

colepeters avatar Aug 23 '22 22:08 colepeters

@jjenzz @benoitgrelard Just checking in — any other changes you'd like to see, or do you reckon this can proceed to workflows & merging? Thanks!

colepeters avatar Aug 31 '22 00:08 colepeters

@benoitgrelard Requested changes are in, let me know if you'd like any other updates!

colepeters avatar Sep 30 '22 18:09 colepeters