From 241306d34d536871ebd07c99d4bcd9d1024ab3df Mon Sep 17 00:00:00 2001 From: andrewwallacespeckle Date: Wed, 20 Aug 2025 11:18:15 +0100 Subject: [PATCH] fix(fe): prevent native context menu on Windows --- .../lib/viewer/composables/contextMenu.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/frontend-2/lib/viewer/composables/contextMenu.ts b/packages/frontend-2/lib/viewer/composables/contextMenu.ts index ebd226e86..266662ba5 100644 --- a/packages/frontend-2/lib/viewer/composables/contextMenu.ts +++ b/packages/frontend-2/lib/viewer/composables/contextMenu.ts @@ -10,6 +10,7 @@ import { useFilterUtilities, useCameraUtilities } from '~~/lib/viewer/composables/ui' +import { useEventListener } from '@vueuse/core' export type ViewerContextMenuModel = { isVisible: boolean @@ -29,6 +30,17 @@ export function useViewerContextMenu(params: { const { copy } = useClipboard() const { zoomExtentsOrSelection } = useCameraUtilities() + // Prevent native context menu on the viewer + useEventListener( + parentEl, + 'contextmenu', + (event: MouseEvent) => { + event.preventDefault() + event.stopPropagation() + }, + { passive: false } + ) + const contextMenuState = ref({ isVisible: false, clickLocation: null, @@ -145,9 +157,6 @@ export function useViewerContextMenu(params: { singleClickCallback: (event, { firstVisibleSelectionHit }) => { // Handle right-clicks to open context menu if (event?.event && event.event.button === 2) { - event.event.preventDefault() - event.event.stopPropagation() - if (firstVisibleSelectionHit) { const clickLocation = firstVisibleSelectionHit.point.clone() const selectedObjectId = firstVisibleSelectionHit.node.model.id