From 0498d661c0e375324be080e6022372fae81ddf78 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sat, 28 Feb 2026 18:05:11 +0300 Subject: [PATCH] Fix context menu: use @floating-ui/vue instead of reka-ui ContextMenu reka-ui's ContextMenuTrigger calls event.preventDefault() after await nextTick(), which is too late to suppress the native context menu in Tauri's webview. Replace with a custom implementation using @floating-ui/vue for positioning (already a transitive dependency) and proper ARIA roles (role=menu/menuitem). - e.preventDefault() called synchronously in our handler - VirtualElement anchor at click coordinates - flip/shift middleware for viewport-aware positioning - onClickOutside + Escape to dismiss - Submenu hover for 'Move to page' - Remove redundant contextmenu handler from use-canvas-input --- src/components/CanvasContextMenu.vue | 387 +++++++++++++-------------- src/composables/use-canvas-input.ts | 13 - 2 files changed, 190 insertions(+), 210 deletions(-) diff --git a/src/components/CanvasContextMenu.vue b/src/components/CanvasContextMenu.vue index 252e30581..4d4d1044d 100644 --- a/src/components/CanvasContextMenu.vue +++ b/src/components/CanvasContextMenu.vue @@ -1,22 +1,27 @@ diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.ts index ca88ff562..fcc09b592 100644 --- a/src/composables/use-canvas-input.ts +++ b/src/composables/use-canvas-input.ts @@ -927,19 +927,6 @@ export function useCanvasInput( }) } - function onContextMenu(e: MouseEvent) { - const { cx, cy } = getCoords(e) - const hit = store.graph.hitTest(cx, cy, store.state.currentPageId) - if (hit) { - if (!store.state.selectedIds.has(hit.id)) { - store.select([hit.id]) - } - } else { - store.clearSelection() - } - } - - useEventListener(canvasRef, 'contextmenu', onContextMenu) useEventListener(canvasRef, 'dblclick', onDblClick) useEventListener(canvasRef, 'mousedown', onMouseDown) useEventListener(canvasRef, 'mousemove', onMouseMove)