Skip to content

Add support for nested menus to @daffodil/design/menu #4559

Description

@xelaint

Feature description

Add support for nested menus to @daffodil/design/menu. Today a <daff-menu> renders a flat list of daff-menu-items. This feature would let a daff-menu-item act as a parent that reveals a child <daff-menu> as a flyout panel, enabling hierarchical menu structures.

Proposed shape — a menu item activates a nested menu much like the existing activator/template pattern:

<ng-template #actionsMenu>
  <daff-menu>
    <button daff-menu-item>Edit</button>

    <!-- parent item that opens a submenu -->
    <button daff-menu-item [daffMenuActivator]="moreMenu">
      More
    </button>

    <a href="/settings" daff-menu-item>Settings</a>
  </daff-menu>
</ng-template>

<ng-template #moreMenu>
  <daff-menu>
    <button daff-menu-item>Duplicate</button>
    <button daff-menu-item>Archive</button>
  </daff-menu>
</ng-template>

Behavior to cover:

  • A parent item indicates it has a submenu (e.g. a trailing chevron / daffSuffix) and exposes aria-haspopup="menu" + aria-expanded.
  • The child menu is positioned as a flyout adjacent to its parent item, with the existing overlay positioning handling collision/repositioning.
  • Opening/closing follows the Menu and Menubar WAI-ARIA pattern the menu already targets, including:
  • Right Arrow on a parent item opens the submenu and focuses its first item.
  • Left Arrow / Escape closes the submenu and returns focus to the parent item.
  • Closing a parent menu closes its open submenus.
  • Submenus should nest to arbitrary depth.

Use case

As a developer, I'd like to be able to group secondary actions under a parent menu item so that long or categorized action lists can be organized hierarchically without overflowing a single flat menu.

Prior work

No response

Daffodil version

0.93.0

Additional context

No response

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions