Skip to content

Commit

Permalink
fix(core): prevent drag click when multi selection is active (#1609)
Browse files Browse the repository at this point in the history
* fix(core): prevent drag click when multi selection is active

Signed-off-by: braks <[email protected]>

* chore(changeset): add

Signed-off-by: braks <[email protected]>

---------

Signed-off-by: braks <[email protected]>
  • Loading branch information
bcakmakoglu committed Sep 6, 2024
1 parent f4bde90 commit 43ed0a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-cups-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vue-flow/core": patch
---

Prevent drag-click handler when multi selection is active.
16 changes: 3 additions & 13 deletions packages/core/src/composables/useDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 43ed0a8

Please sign in to comment.