Skip to content

rune-kit Menu and PopupList: submenus have no keys or hover-open, items are keyed by position, names can't differ from the drawn text, and list items take no rich label #1387

Done

Description

@wmfeht

Context: Strata (lgse/strata), a file manager on Rune.

What's missing (67d73a5f):

  • Submenu keyboard & hover: MenuItem::submenu(entries, open) (rune-kit/src/overlays/menu.rs:103-106, 222-236) opens only when the app sets it open; VERTICAL_ROLES (runtime/input/focus.rs:6) gives "menu" only Up/Down/Page/type-select — no Right, Left, Enter or Space on a submenu row to enter/leave it, and no hover-open with delay.
  • Positional item keys: MenuItem is keyed by position {key}-item{i} (overlays/menu.rs:336), so a row inserted above the focused one moves focus.
  • Accessible names: Menu (overlays/menu.rs:244-322) takes no .label(...), and MenuItem uses its drawn text for .label(self.label) (:168), so a middle-elided breadcrumb item reads shortened.
  • Rich PopupList items & reuse: PopupItem (overlays/popup_list.rs:15-61) takes only a String label (no spans or label_with(El)), so a completion list can't bold/colour the matched part, and PopupListCore::build_list (:167) is pub(super), so an app can't reuse the list inside its own popup.

Ask. Right, Left, Enter and Space on submenu rows with focus moving into the submenu, and hover-open with a delay; MenuItem::key; Menu::label and MenuItem::label apart from the drawn text; PopupItem::label_with(El) (or spans) and a public PopupList::build_list.

Related: #529, #539, #1070, #1364.

Activity

  1. Hona commented on Nov 24, 2026

    @Hona
    Member

    Part of this is now on dev in #1964 (cd4ad9a70), keeping this issue open for the remaining submenu interaction work.

    Shipped in #1964 (cd4ad9a70)

    • MenuItem::key(impl Into<String>) for stable item keys (blank falls back to positional {menu_key}-item{i}, preserving focus when rows are inserted above and anchoring submenus to {key}).
    • Menu::label(impl Into<String>) and MenuItem::a11y_label(impl Into<String>) for accessible names independent of drawn text (following WAI-ARIA APG; MenuItem::a11y_label also drives menu typeahead and names open submenus, and role="menu" now mirrors with aria-label on the web). Named a11y_label rather than label so it stays distinct from the drawn text passed to MenuItem::new—let us know if you would prefer a different name.
    • PopupItem::label_with(El) (hides custom spans from assistive tech while keeping PopupItem::new's string as the option's accessible name) and PopupList::build_list(&Kit) -> El for standalone reuse.
    let item = MenuItem::new("…/menu.rs").key("menu-rs").a11y_label("crates/rune-kit/src/overlays/menu.rs");
    let menu = Menu::new("file").label("File actions").item(item);
    let list = PopupList::<App>::new("cmds", "").label("Commands")
        .items([PopupItem::new("rev", "/review").label_with(row().child(text("/rev")).child(text("iew")))])
        .build_list(&k);

    Examples are in examples/kit-gallery (rune-menu--submenu-options and rune-popup-list--rich-inline).

    • Tested: headless layout, focus, AccessKit, and web-mirror tests on Windows and macOS, Linux aarch64 compile check, wasm32/WebGL2 compile checks, and headless Chromium software WebGPU/WebGL2 smoke checks.
    • Not run live: no live GUI window or real screen reader was launched.

    Still open on this issue

    • Submenu keyboard navigation (Right/Left/Enter/Space to open/enter/leave a submenu).
    • Submenu hover-open delay timers.
  2. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up. As noted above, #1964 already shipped MenuItem::key, Menu::label / MenuItem::a11y_label, PopupItem::label_with(El) and a public PopupList::build_list, so this issue now covers only the submenu interaction.

    On current dev, MenuItem::submenu(entries, open) (crates/rune-kit/src/overlays/menu.rs) still opens only when the app sets open, and VERTICAL_ROLES (crates/rune/src/runtime/input/focus.rs) still gives "menu" only vertical navigation. I found no submenu key handling and no hover-open delay. What's left:

    • On a submenu row, Right / Enter / Space open the submenu and move focus to its first item; Left (and Escape inside it) closes the submenu and returns focus to the parent row. Left and Right swap for submenus placed on the left or in right-to-left layouts.
    • Pointer hover over a submenu row opens it after a short delay, and leaving closes it.

    I'll keep this open as a feature request for that work.

  3. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    I've opened a PR for the remaining submenu work. It adds MenuItem::on_submenu(|s, open| ..), which hands the menu your submenu open flag:

    • Keys on a submenu row: Right, Return or Space opens the submenu and moves focus to its first item.
    • Keys inside the submenu: Left or Escape closes just the submenu and puts focus back on the row. In a menu with on_close, the parent menu stays open.
    • Right to left: the arrows swap, matching the chevron. A submenu that flips sides only because it ran out of room keeps Right to open and Left to close.
    • Hover: resting the pointer 200 ms on the row opens its submenu, and resting on another row of the same menu (disabled rows included) closes it.
    • Closing the menu: Escape, a press outside, or picking an item (other than a checkbox or radio) also closes the open submenus through your callback, so the menu reopens with them closed. If you close the menu any other way, clear the flags yourself.
    MenuItem::new("Open With")
        .submenu(apps, s.open_with)
        .on_submenu(|s: &mut App, open| s.open_with = open)

    All on_submenu callbacks in one menu need to use the same state type. These were checked in headless tests only, not in a live window or with a screen reader.

    Fixed in #2204.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions