BUG-048
ID:BUG-048Status:fixed

The menubar nav behaviour skips every group, so menubars get no ARIA or keyboard support

Found by the behaviour audit for SPEC-196 D6. Confirmed by reading the code; not yet reproduced in a browser.

The menubar behaviour finds each group's list as a direct child of the group:

Severity:majorMilestone:v0.50.0Source:SPEC-196
changeset-release/main View source
Branches 3
History 4
  1. b6b4109
    Content editedby github-actions[bot]
  2. f8b371f
    Created (reported)by github-actions[bot]
  3. 59607e7
    Content editedby Claude
    plan: v0.50.0 milestone, "Nothing reads a class"
  4. 1a7f1b9
    Content editedby Claude
    plan: file BUG-048; SPEC-196 D10 renames blocks to rune names

Steps to Reproduce

  1. Write a menubar nav with at least one group:

    {% nav layout="menubar" %}
    ## Docs
    - getting-started
    - installation
    {% /nav %}
    
  2. Load the page with behaviours enabled, and inspect the group heading.

  3. Tab to the heading and press ArrowDown, then Escape.

Expected

The behaviour wires each group as a WAI-ARIA menubar item, as its own doc comment describes:

  • the heading gets role="button", tabindex="0", aria-haspopup and aria-expanded, with an id the panel references;
  • a click toggles the group's data-open, and only one group is open at a time;
  • ArrowLeft and ArrowRight move between triggers, ArrowDown enters the open submenu, and Escape closes it and returns focus.

Actual

None of that happens: no group is wired. The panels still open on hover and on :focus-within, through the skeleton's fallback rules (packages/skeleton/styles/runes/nav.css:80–82), so mouse users see working dropdowns and the defect is easy to miss. Keyboard and screen-reader users get no menubar semantics: no roles, no expanded state, no arrow-key navigation, and no Escape.

Environment

  • main as of 2026-11-09.
  • There is no behaviour test for the menubar. Nav tests in packages/runes/test cover the schema and auto-enrichment, not navMenubarBehavior.

Approach

  • Select the panel as :scope > [data-name="panel"], the element SPEC-054 introduced and the CSS already styles. That is also the selector SPEC-196 D6 asks for, since it uses the vocabulary rather than an element name.
  • Check the other :scope > … lookups in the same file against the current output, notably the mobile trigger (:scope > [data-name="trigger"]).
  • Add a DOM test (jsdom, as the other behaviour tests use) that renders a menubar nav through the real schema and asserts the roles and the keyboard model, so the schema and the behaviour cannot drift apart again.

References

  • SPEC-196 D6: the behaviour audit that found it.
  • SPEC-054: the panel wrapper.

Resolution

Completed: 2026-11-09

Branch: claude/rune-composition-layout-convention-hkqrzx

What was done

  • packages/behaviors/src/behaviors/nav-menubar.ts: the panel lookup is :scope > [data-name="panel"] instead of :scope > ul, :scope > ol.
  • packages/content/test/nav-menubar-behaviour.test.ts (new): renders a menubar nav through the real nav schema and engine into jsdom, and asserts every group is wired (roles, aria-haspopup/aria-expanded/aria-controls, role="menu"), one group open at a time on click, the keyboard model (ArrowRight between triggers, ArrowDown into the submenu, Escape closes and returns focus), and the mobile trigger. The first three tests fail on the old selector (verified by reverting it).
  • Changeset: @refrakt-md/behaviors patch.

Notes

  • The test lives in @refrakt-md/content because it needs the schema, the engine and the behaviour together, as composition-behaviour.test.ts already does.
  • The mobile trigger lookup (:scope > [data-name="trigger"]) was checked against the output and is correct; it now has a test too.