Merge pull request #4498 from xyflow/fix-pointer-capture

only capture pointer after valid selection has started
This commit is contained in:
Moritz Klack
2024-07-30 14:22:26 +02:00
committed by GitHub
3 changed files with 10 additions and 2 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@xyflow/react': patch
'@xyflow/svelte': patch
---
fix(pane) only capture pointer after a valid selection has started, fixes #4492
+2 -1
View File
@@ -120,7 +120,6 @@ export function Pane({
const onPointerDown = (event: ReactPointerEvent): void => {
const { resetSelectedElements, domNode, edgeLookup } = store.getState();
containerBounds.current = domNode?.getBoundingClientRect();
(event.target as Element)?.setPointerCapture?.(event.pointerId);
if (
!elementsSelectable ||
@@ -132,6 +131,8 @@ export function Pane({
return;
}
(event.target as Element)?.setPointerCapture?.(event.pointerId);
selectionStarted.current = true;
selectionInProgress.current = false;
edgeIdLookup.current = new Map();
@@ -92,7 +92,6 @@
function onPointerDown(event: PointerEvent) {
containerBounds = container.getBoundingClientRect();
(event.target as Element)?.setPointerCapture?.(event.pointerId);
if (
!elementsSelectable ||
@@ -104,6 +103,8 @@
return;
}
(event.target as Element)?.setPointerCapture?.(event.pointerId);
const { x, y } = getEventPosition(event, containerBounds);
unselectNodesAndEdges();