From 0d2cda7dff46faa373c918ebe5a0db85ac75cbba Mon Sep 17 00:00:00 2001 From: peterkogo Date: Thu, 30 Oct 2025 12:42:55 +0100 Subject: [PATCH] also postpone starting selection when clicking on a node --- packages/react/src/container/Pane/index.tsx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/packages/react/src/container/Pane/index.tsx b/packages/react/src/container/Pane/index.tsx index 94f23c35..43c55383 100644 --- a/packages/react/src/container/Pane/index.tsx +++ b/packages/react/src/container/Pane/index.tsx @@ -121,7 +121,7 @@ export function Pane({ // We are using capture here in order to prevent other pointer events // to be able to create a selection above a node or an edge const onPointerDownCapture = (event: ReactPointerEvent): void => { - const { resetSelectedElements, domNode } = store.getState(); + const { domNode } = store.getState(); containerBounds.current = domNode?.getBoundingClientRect(); if (!containerBounds.current) return; @@ -155,13 +155,6 @@ export function Pane({ event.stopPropagation(); event.preventDefault(); } - - if (paneClickDistance === 0 || selectionKeyPressed) { - resetSelectedElements(); - - onSelectionStart?.(event); - selectionInProgress.current = true; - } }; const onPointerMove = (event: ReactPointerEvent): void => { @@ -184,14 +177,10 @@ export function Pane({ const { x: mouseX, y: mouseY } = getEventPosition(event.nativeEvent, containerBounds.current); const { startX, startY } = userSelectionRect; - if ( - !selectionInProgress.current && - event.target === container.current && - !selectionKeyPressed && - paneClickDistance > 0 - ) { + if (!selectionInProgress.current) { + const requiredDistance = selectionKeyPressed ? 0 : paneClickDistance; const distance = Math.hypot(mouseX - startX, mouseY - startY); - if (distance <= paneClickDistance) { + if (distance <= requiredDistance) { return; } resetSelectedElements();