LanternUI.Components.Menu (LanternUI v0.8.2)

Copy Markdown View Source

Menu button and menubar — no Fluxon equivalent. Clean-room implementations of the WAI-ARIA APG menu-button and menubar patterns.

<.menu id="file-actions" label="File">
  <.menu_item phx-click="new">New</.menu_item>
  <.menu_item phx-click="open">Open…</.menu_item>
  <.menu_separator />
  <.menu_item phx-click="delete" data-danger>Delete</.menu_item>
</.menu>

<.menubar label="Editor">
  <.menubar_menu label="File">
    <.menu_item phx-click="new">New</.menu_item>
  </.menubar_menu>
  <.menubar_menu label="Edit">
    <.menu_item phx-click="undo">Undo</.menu_item>
  </.menubar_menu>
</.menubar>

How this differs from dropdown: the component owns the trigger button, so aria-haspopup/aria-expanded/aria-controls are always wired (a custom trigger is content inside the button via the :trigger slot, never a replacement button), the popup is an aria-labelledby-named role="menu", and the hooks run the full APG keyboard model — wrapping ArrowUp/Down, Home/End, roving tabindex, and (for the menubar) horizontal ArrowLeft/Right across top-level items that carries an open submenu along.

ARIA ownership split: the server renders aria-expanded="false" as a static literal and every popup item tabindex="-1"; the LanternMenu / LanternMenubar hooks own both at runtime (expanded state and the roving tabindex). Focus moves by roving DOM focus, the library-wide model — not aria-activedescendant.

Summary

Functions