table: pass click modifiers through SelectRow event - #2231
Conversation
|
Duplicate PR #2232? |
|
Not a duplicate of #2232. These are separate changes:
#2232 depends on this PR because both touch |
SelectRow now carries Modifiers so consumers can implement Cmd+click / Shift+click multi-select without intercepting mouse events on the row div (which breaks on_drag on children). Also adds set_parent_menu() on PopupMenu for external submenu wiring. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19bb64c to
16646ec
Compare
|
Closing in favor of using GPUI's existing Consumers of Verified locally — multi-row selection works as expected. Closing #2228 alongside. |
## 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>
Fixes #2228
Summary
SelectRow(usize)toSelectRow(usize, Modifiers)to carry keyboard modifiers from the click eventset_selected_row_with_modifiers()alongside the existingset_selected_row()(which passes default modifiers)on_dragon child elements)AI Disclosure
This code was generated with AI assistance (Claude). The implementation has been manually tested in a production GPUI application with multi-row selection and native macOS drag.