Background/Goal
The <select> element can use the <optgroup> element to show groups of options. We should enable grouping and optgroup headers in the Menu component so users can show grouped MenuItems:
User stories
- As a designer or developer, I want to be able to provide a Select or other menu component that has named grouped options.
Design spec
Depending on whether menu groups have a clear title to include in the menu item set, they could be grouped in two different ways:
- Using headers: A prominent bold @color-emphasized header can be added as a title to group a set of menu items. Each group with a header will be separated by @spacing-75 (12px) for clearer distinction.
- Using dividers: In those cases where there is no clear title to include in the groups, a @border-color-muted divider can be used to separate them.
Component's Guidelines
- Patch with the guidelines updates: https://gerrit.wikimedia.org/r/c/design/codex/+/1073431
Open questions
- Should we design/build this as a special type of MenuItem, or design/build the headings into the Menu component instead? What's the most sensible way for developer users to add groupings of MenuItems?
Acceptance criteria (or Done)
Design
- Design the Figma spec sheet and add it in this task
- Update the component in the Figma library. This step will be done by a DST member.
- Update the Menu guidelines including info about the grouping (patch 1073431)
Code
- The Menu component is updated to enable grouping of MenuItems
- Components that use the Menu component (e.g. Select and Lookup) should support grouped MenuItems
- The grouped menu items should still be accessible to keyboard nav and voiceover (following guidance from the APG)