Repository navigation
feat: [menu, context-menu] add checkbox, radio, and link items - #953
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review.
|
commit: |
de3c0ea to
1346196
Compare
Menu.EmptyState and ContextMenu.EmptyState go back to a plain element that the app shows and hides. Menu.Status, ContextMenu.Status, and the shared item count are removed, with their docs, demos, and tests.
A filtered-out checkbox item unmounted the Base UI item, and a group switched to a fragment while filtering, which remounted its items. Both reset uncontrolled checked and radio values. The checkbox item now holds its checked state, and groups stay rendered while filtering. The empty-list styles ignore groups that have no matches.
In a searchable menu, Menu.EmptyState and ContextMenu.EmptyState render Base UI Autocomplete.Empty, a polite live region. The app still decides what it shows. An empty state with no children has no padding, so it can stay mounted.
Export the props types of CheckboxItem, RadioGroup, RadioItem, and LinkItem for Menu and ContextMenu.
Remove an unused handler argument and an unused test import.
…dio-link-items Resolve conflicts in the menu and context-menu index files, packages/react/index.tsx, and menu-misc.tsx. Keep both export lists, and keep the MenuEmptyStateProps signature from main with the Autocomplete.Empty body.
…chable empty state The search list is a listbox, which only allows options and groups inside. Autocomplete.Empty sets role status, aria-live and aria-atomic, and axe reports the element as a child the listbox does not allow.
Summary
Add
CheckboxItem,RadioGroup,RadioItem, andLinkItemtoMenuandContextMenu. Checkbox and radio items draw a check mark or dot before the leading icon.LinkItemrenders an<a href>and takes a router link throughrender. All four filter and keeparia-checkedin the searchable (autocomplete) mode.Rebuild
Menu.EmptyStateandContextMenu.EmptyStateon Base UIAutocomplete.Emptyin the searchable mode (a polite live region elsewhere). AddMenu.StatusandContextMenu.Status, a hidden live region that announces the match count. Items register into a small count context, because our menus filter their own children and do not passitemsto Base UI.Add data-slots for every new part, with tests and Slots tables. Update props, demos, and docs for both components.
Why it's like this: the old Ariakit menu had a
type="select"cell that drew a checkbox picture with no checked state. The Base UI migration (feat: migrate DropdownMenu to BaseUI #652) removed it and did not add CheckboxItem or RadioItem, likely because they do not plug into the Autocomplete-based searchable menu easily. LinkItem was added to Base UI two weeks before that migration.Menu.EmptyStatedates from Nov 2024 and was kept as a plain div.Breaking: small.
Menu.EmptyStateandContextMenu.EmptyStatenow show and hide on their own. They show their children only when the menu renders no items.I have followed the pull request section of the contributing guide.