#3336

Keep the text selection highlight visible while a context menu is open

OpenSunJaryopened 1mo ago

Summary

On a multi-line Input, opening a framework-rendered context menu (the generic ContextMenuExt::context_menu PopupMenu, e.g. a custom right-click menu attached to the input) makes the selected-text highlight disappear until the menu closes. The user then can't see what Cut / Copy / Select All will apply to.

Current behavior

  • ContextMenuExt::context_menu (PopupMenu) takes focus while open: build_menu calls focus_handle.focus(window, cx).
  • layout_selections() in crates/base/src/input/base/element.rs early-returns when the input is not focused: if !state.focus_handle.is_focused(window) { return vec![]; }
  • So while the menu is open the selection path is never produced and no highlight is painted. It comes back immediately after dismiss.

Note: the same disappearance also happens with the input's own built-in menus (completion / code actions), because layout_selections is gated only on focus and never consults is_context_menu_open. The OS-native right-click menu (handle_right_click_menu → NativeMenu) keeps the highlight, because it never takes focus away.

Steps to reproduce

  1. Multi-line Input (plain multi-line or InputMode::CodeEditor).
  2. Select a range of text.
  3. Open a context menu over the input — either the generic ContextMenuExt::context_menu PopupMenu (right-click) or one of the built-in menus (completion / code actions).
  4. While the menu is open the selection highlight is gone; it returns on dismiss.

Environment

  • GPUI Component: 0.5.2 (rev 88f102d) and current main (caf830c0, gpui-kit / gpui-base layout) — both reproduce
  • Platform: Windows 11

Expected

The selected-text highlight stays visible while a context menu is open, so the user can confirm which text the menu actions will affect (matching the native-menu behavior).

Activity

1
l-raider28d ago

I can confirm this issue on Linux as well.