Skip to content

feat(rune-kit): add Menu/MenuItem submenu placement, keys, a11y_label, and PopupList label_with/build_list - #1964

Merged
Hona merged 1 commit into
devfrom
feat/1070-menu-submenu-keys-popup-list
Nov 24, 2026
Merged

Hona merged 1 commit into
devfrom
feat/1070-menu-submenu-keys-popup-list

Conversation

@Hona

@Hona Hona commented Nov 24, 2026

Copy link
Copy Markdown
Member

Fixes #1070
Refs #1387

Adds per-submenu placement and minimum width, stable menu item keys, distinct menu/item accessible names, rich PopupItem labels, and standalone PopupList reuse while preserving all existing defaults.

API

// Left-placed, content-sized submenu with stable keys and distinct accessible names
Menu::new("http")
    .label("HTTP settings")
    .item(
        MenuItem::new("…/overlays/menu.rs")
            .key("menu-rs")
            .a11y_label("crates/rune-kit/src/overlays/menu.rs"),
    )
    .item(
        MenuItem::new("HTTP version")
            .key("http-version")
            .submenu(versions, s.sub_open)
            .submenu_placement(Placement::LeftStart)
            .submenu_min_width(0.0),
    )
    .open(s.open)
    .build(&k, &mut layer);

// Standalone listbox with rich inline labels keeping plain accessible names
let list = PopupList::new("completions", "")
    .label("Completions")
    .items([
        PopupItem::new("review", "/review")
            .label_with(row().child(text("/rev").font(k.ty.ui_medium)).child(text("iew")))
            .description("Review branch changes"),
    ])
    .active(s.active)
    .on_choose(|s: &mut App, id, _| s.pick(id))
    .build_list(&k);

Changes

  • crates/rune-kit/src/overlays/menu.rs:
    • MenuItem::submenu_placement(Placement) (default Placement::RightStart) and MenuItem::submenu_min_width(f32) (default 160.0, 0.0 sizes to content; negative/non-finite clamp to 0.0).
    • MenuItem::key(impl Into<String>) for explicit element keys (blank falls back to positional {menu_key}-item{i}), keeping focus stable when rows are inserted above and anchoring submenus to {key}.
    • MenuItem::a11y_label(impl Into<String>) for an accessible name distinct from the drawn text (also drives focus_group typeahead and names open submenus; blank falls back to drawn text).
    • Menu::label(impl Into<String>) for the role="menu" surface name (blank leaves it unnamed).
  • crates/rune-kit/src/overlays/popup_list.rs:
    • PopupItem::label_with(El) renders custom label content (marked a11y_hidden) while keeping PopupItem::new's plain string as the option's accessible name.
    • PopupList::build_list(self, k: &Kit) -> El returns the scrollable listbox element without anchoring it into an overlay layer, honouring animate_filtering.
  • crates/rune/src/a11y/roles.rs:
    • Marks role="menu" as an aria_container() so Menu::label and submenu menu names mirror as <div role="menu" aria-label="..."> in the web accessibility mirror alongside listbox, dialog, and tablist.
  • Example & docs:
    • Added rune-menu--submenu-options and rune-popup-list--rich-inline stories in examples/kit-gallery, rustdoc examples on every new public item, crates/rune-kit/README.md, and changelog/unreleased/2026-11-25-menu-submenu-keys-and-popup-list-reuse.md.

Outside answer followed

Not run live

  • No live GUI window or real screen reader was launched; checked via headless Runtime layout/focus/AccessKit/web-mirror tests on Windows and macOS, Linux aarch64 compile check, wasm32/WebGL2 compile checks, and headless Chromium software WebGPU/WebGL2 smoke runs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rune-kit: a submenu always opens right, at a fixed 160 pt floor, with no way to place it

1 participant