Skip to content

feat(anchor,popup-menu): clamp cross-axis anchored_fit for submenus and add App::on_field_menu / Tx::resolve_field_menu fallback - #2025

Merged
Hona merged 1 commit into
devfrom
feat/529-submenu-fit-field-menu
Nov 24, 2026
Merged

Hona merged 1 commit into
devfrom
feat/529-submenu-fit-field-menu

Conversation

@Hona

@Hona Hona commented Nov 24, 2026

Copy link
Copy Markdown
Member

Fixes #529

Summary

  • Cross-axis El::anchored_fit clamping and side-placed submenu fitting (crates/rune/src/runtime/anchor.rs, crates/rune/src/el/anchor.rs, crates/rune-kit/src/overlays/popover.rs):
    • fit_anchored now bounds overflowing El::anchored_fit surfaces on both the main axis (fit_bound) and the cross axis (cross_fit_bound, bounds_span - 2 * MARGIN), lowering definite min_width/min_height floors when they exceed the available room so CSS/Taffy min-over-max precedence cannot push a floored surface past the window or El::anchored_in boundary.
    • rune_kit::popover::fit now applies El::anchored_fit for Side::Left | Side::Right as well as Top | Bottom, so overflowing rune_kit::Menu submenus stay inside small windows (such as 420×400) and scroll vertically. Surfaces that already fit on either side and within viewport height are unchanged.
    • Follows Floating UI's size middleware (viewport-bounded availableWidth and availableHeight) and Rune's documented window-containment contract.
  • Opt-in text-field menu fallback (crates/rune/src/popup_menu/mod.rs, crates/rune/src/runtime/input/field_menu.rs, crates/rune/src/app.rs, crates/rune/src/app/config.rs, crates/rune/src/window/spec.rs, crates/rune/src/overlay/options.rs):
    • Added FieldMenuRequest (field_key, field_path, point, menu, into_menu), App::on_field_menu (also on WindowSpec and ConfiguredOverlay), and Tx::resolve_field_menu(Option<&str>).
    • When !popup_menu_supported() (e.g. Linux) and on_field_menu is registered, right-clicking a text field or pressing Menu / Shift+F10 delivers the ready-built PopupMenu (inspectable via PopupMenu::entries()) to the hook instead of queuing a native popup; tx.resolve_field_menu(Some(id)) restores field focus if needed and runs the matching action (Cut, Copy, Paste, Select All, spelling suggestions, Learn Spelling, spellcheck toggle/languages).
    • Strictly opt-in and additive: macOS and Windows native menus and apps without on_field_menu are unchanged. Native Linux xdg_popup windows remain tracked in Real popups: a popup of the window's tree, shown in a native window of its own #1369.
flowchart LR
    A[Right-click / Shift+F10 on text_input] --> B{popup_menu_supported()?}
    B -- yes --> C[Queue native PopupMenu]
    B -- no --> D{App::on_field_menu set?}
    D -- no --> C
    D -- yes --> E[Deliver FieldMenuRequest with PopupMenu]
    E --> F[App renders in-window Menu via PopupMenu::entries]
    F --> G[Tx::resolve_field_menu Some id / None]
    G --> H[field_menu_pick runs action on field]
Loading
App::new(spec).on_field_menu(|s: &mut MyApp, req: FieldMenuRequest, _| {
    s.field_menu = Some(req);
});

// On menu item select:
tx.resolve_field_menu(Some(id));

Examples & docs

  • examples/kit-gallery: added rune-menu--submenu-small-window (8/20-row "Open With" submenu clamping and scrolling inside 420×400) and rune-menu--field-menu-fallback (wired to App::on_field_menu and Tx::resolve_field_menu).
  • Updated rustdoc on El::anchored_fit, popover::anchored, FieldMenuRequest, App::on_field_menu, WindowSpec::on_field_menu, ConfiguredOverlay::on_field_menu, and Tx::resolve_field_menu, plus crates/rune/README.md, crates/rune-kit/README.md, and changelog/unreleased/2026-11-25-submenu-fit-and-field-menu-fallback.md.

…nd add App::on_field_menu / Tx::resolve_field_menu fallback
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.

Linux: popup_menu is unsupported, so a text field's menu shows nothing, and in-window submenus can't leave the window

1 participant