menu: fix submenu dismiss propagation and ESC handling (#2232)
## Summary Fixes #2229 — three related fixes for submenu dismiss behavior in `PopupMenu`: 1. **Auto-wire `parent_menu` in `render()`**: Submenus added via `PopupMenuItem::submenu()` (the data constructor) don't get `parent_menu` set, unlike `PopupMenu::submenu()` (the builder method). This breaks the dismiss chain. Now `PopupMenu::render()` auto-wires `parent_menu` on any submenu child that doesn't have it set. This is needed because table delegates operate in `Context<TableState>` and cannot call `PopupMenu::submenu()` which requires `Context<PopupMenu>`. 2. **Fix ESC not closing menus when a submenu is open**: When a submenu is opened by hover, the parent menu retains focus. Pressing ESC would hit the parent's `dismiss()`, which bailed out early because `active_submenu()` was `Some`. Split `dismiss` into `dismiss` (ESC action handler that clears the active submenu first) and `dismiss_menu` (internal dismiss that propagates up the chain). 3. **Guard `handle_dismiss` for submenu clicks**: `handle_dismiss` (click-outside) returns early if a submenu is active. Without this, clicking a submenu item triggers the parent's `on_mouse_down_out`, tearing down the submenu before the item's `on_click` fires. Changes are in `popup_menu.rs` only — no table code changes needed. No dependency on #2231. ## AI Disclosure Implementation was developed with AI assistance (Claude). All code has been reviewed, tested, and follows existing `popup_menu.rs` patterns. ## Test plan - [x] `cargo run --example table` — right-click context menu with submenus works - [x] `cargo run` (story) — Menu story context menu: ESC closes full chain - [x] Submenu item click fires handler and dismisses menu - [x] Click outside closes all menus - [x] Hover navigation between submenus still works --------- Co-authored-by: Jason Lee <huacnlee@gmail.com>
B
BBS committed
e12e39ca55051d02f0e2ae8a910a674905c722d6
Parent: cac67ad
Committed by GitHub <noreply@github.com>
on 8/10/2026, 11:36:30 AM