From 43ed0a831801d507697ff8831ecee6cb44036ba4 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:16:37 +0200 Subject: [PATCH] fix(core): prevent drag click when multi selection is active (#1609) * fix(core): prevent drag click when multi selection is active Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --- .changeset/swift-cups-pay.md | 5 +++++ packages/core/src/composables/useDrag.ts | 16 +++------------- 2 files changed, 8 insertions(+), 13 deletions(-) create mode 100644 .changeset/swift-cups-pay.md diff --git a/.changeset/swift-cups-pay.md b/.changeset/swift-cups-pay.md new file mode 100644 index 00000000..30583b73 --- /dev/null +++ b/.changeset/swift-cups-pay.md @@ -0,0 +1,5 @@ +--- +"@vue-flow/core": patch +--- + +Prevent drag-click handler when multi selection is active. diff --git a/packages/core/src/composables/useDrag.ts b/packages/core/src/composables/useDrag.ts index c84f8f5e..f6642970 100644 --- a/packages/core/src/composables/useDrag.ts +++ b/packages/core/src/composables/useDrag.ts @@ -229,24 +229,14 @@ export function useDrag(params: UseDragParams) { } const eventEnd = (event: UseDragEvent) => { - if (!dragStarted) { - const pointerPos = getPointerPosition(event) - - const x = pointerPos.xSnapped - (lastPos.x ?? 0) - const y = pointerPos.ySnapped - (lastPos.y ?? 0) - const distance = Math.sqrt(x * x + y * y) - - // dispatch a click event if the node was attempted to be dragged but the threshold was not exceeded - if (distance !== 0 && distance <= nodeDragThreshold.value) { - onClick?.(event.sourceEvent) - } - - return + if (!dragging.value && !multiSelectionActive.value) { + onClick?.(event.sourceEvent) } dragging.value = false autoPanStarted = false dragStarted = false + lastPos = { x: undefined, y: undefined } cancelAnimationFrame(autoPanId)