-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
What
This conversation was started in #35142 (comment)
We should look into refactoring MenuGroup and MenuItem to rely on the lower level ItemGroup and Item. This would enable the usage of MenuGroup and MenuItem outside of DropdownMenu and would give us a chance to enforce a more consistent look&feel (including spacing) across menu layouts.
Why
The MenuGroup and MenuItem components were created as high-level components, tailored to be used inside the DropdownMenu component. As such, they are quite opinionated in terms of:
- the component that
MenuItemrenders (which is always aButton) - the internal layout of each
MenuItem - the aria roles (
DropdownMenuis supposed to haverole="menu",MenuGroupwould haverole="group"andMenuItemtherole="menuitem") - and more.
On the other hand, the recently introduced ItemGroup and Item components offer a more low-level approach, are much less opinionated and rely on composition with other components. Their low-level approach can require a lot of tweaking when used directly in complex UIs, and therefore can easily lead to inconsistencies when used in different parts of the editor.
That's why we should look into uniforming the look&feel of menus across different UI patterns (dropdown menus, navigation menus, modal menus, sidebar menus...) and consider rewriting MenuGroup and MenuItem using ItemGroup and Item, with the intention of unlocking their usage in more situations outside of DropdownMenu.
A/C
- Find a way to ensure consistent spacing for all menus using both
ItemGroup/ItemandMenuGroup/MenuItem, matching the spacing of other existing components (e.g. aligning with the icons in theModalcomponent). - Convert
MenuGroupandMenuItemto TypeScript, switch to the new styling system, and hook to the Context System - Rewrite
MenuGroupandMenuItemto use internallyItemGroupandItemand expose more flexibility