From 7ae36ee832def29ecdcc55116f02182863c9c70d Mon Sep 17 00:00:00 2001 From: Freedom <48708512+xddcode@users.noreply.github.com> Date: Tue, 28 Jul 2026 20:15:30 +0800 Subject: [PATCH] fix(desktop): keep context submenu open while scrolling --- .../src/components/ui/CustomContextMenu.vue | 14 ++++++- .../ui/__tests__/CustomContextMenu.spec.ts | 42 +++++++++++++++++++ .../customContextMenuRegistry.spec.ts | 27 +++++++++++- .../ui/customContextMenuRegistry.ts | 18 +++++++- 4 files changed, 96 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/components/ui/CustomContextMenu.vue b/apps/desktop/src/components/ui/CustomContextMenu.vue index a3075858e..1ff159c91 100644 --- a/apps/desktop/src/components/ui/CustomContextMenu.vue +++ b/apps/desktop/src/components/ui/CustomContextMenu.vue @@ -70,7 +70,16 @@ function onPointerDownOutside(e: PointerEvent) { } } -function onScroll() { +function isScrollInsideMenu(e: Event): boolean { + const target = e.target; + if (!(target instanceof Node)) return false; + return !!(menuRef.value?.contains(target) || subRef.value?.contains(target)); +} + +function onScroll(e: Event) { + // Submenus (and tall main menus) are scrollable; ignore their own scroll + // so wheel/trackpad scrolling does not dismiss the menu. + if (isScrollInsideMenu(e)) return; close(); } @@ -262,7 +271,7 @@ onBeforeUnmount(() => { -
+