Background
Currently the menu component can only be triggered by a Select or Lookup component. We want to expand this to include the ability to trigger a menu with a button.
Known use cases
- The Catalog Table in the metrics platform will need this capability
- Multi-blocks project
Existing implementations
Wikifunctions currently triggers a menu through a button, see under "Try this function": https://www.wikifunctions.org/view/en/Z10012
Codex implementation
- Should be implemented as a new standalone "MenuButton" component. This component will be built on top of the ToggleButton (in "quiet" state) and will use the existing Menu component for its menu, similar to other menu-based components (Select, ComboBox, etc).
- Will be introduced as a WIP component initially
- May need to expose props to accept MenuConfig and/or MenuItemData objects
- useFloatingMenu composable should be used for positioning the fly-out menu; however, some tweaks may be needed because we don't want the width of the menu to be limited to the width of the triggering button. The composable may need to be updated to accept an additional argument for this usage. See how Select or Combobox use the composable to position their own Menus for examples.
- Should follow guidelines for the Menu Button Pattern from the Aria Authoring Practices Guide as closely as possible
Open questions
- What will be the minimum and maximum width of the menu when it is displayed?
- What will be the position of the menu when it is displayed?
- Can destructive actions be included within the menu if MenuButton? - Yes, destructive actions will be displayed just within the menu of MenuButton since the rest of the menus (Select, Combobox, Lookup...) contain options instead. We can make it so that the MenuButton accepts menu items with an additional option of whether to show up as "destructive".
Design spec
Component's Guidelines
Once the guidelines of this component have been documented, link them here.
Guidelines documentation |
Acceptance criteria
- A new MenuButton conforming to the above implementation has been added as a WIP component (not published yet).
- A basic demo for the MenuButton has been added to the Codex sandbox page
- Basic unit tests for the component have been added (more comprehensive ones can be added later)
- (optional) If time allows, a page in the docs site can be added as well, but this is not a requirement.
Minimum viable product
TBD
MVP scope
- List all parts of the MVP scope for this component
Design
- Design the Figma spec sheet and add a link to it in this task
- Include the main component in the Figma library. This step will be done by a DST member.
- Document the component Guidelines and include them in Codex
Code
- Implement the component in Codex