Skip to content

Commit 43ed0a8

Browse files
committed
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>
1 parent f4bde90 commit 43ed0a8

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

.changeset/swift-cups-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": patch
3+
---
4+
5+
Prevent drag-click handler when multi selection is active.

packages/core/src/composables/useDrag.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,24 +229,14 @@ export function useDrag(params: UseDragParams) {
229229
}
230230

231231
const eventEnd = (event: UseDragEvent) => {
232-
if (!dragStarted) {
233-
const pointerPos = getPointerPosition(event)
234-
235-
const x = pointerPos.xSnapped - (lastPos.x ?? 0)
236-
const y = pointerPos.ySnapped - (lastPos.y ?? 0)
237-
const distance = Math.sqrt(x * x + y * y)
238-
239-
// dispatch a click event if the node was attempted to be dragged but the threshold was not exceeded
240-
if (distance !== 0 && distance <= nodeDragThreshold.value) {
241-
onClick?.(event.sourceEvent)
242-
}
243-
244-
return
232+
if (!dragging.value && !multiSelectionActive.value) {
233+
onClick?.(event.sourceEvent)
245234
}
246235

247236
dragging.value = false
248237
autoPanStarted = false
249238
dragStarted = false
239+
lastPos = { x: undefined, y: undefined }
250240

251241
cancelAnimationFrame(autoPanId)
252242

0 commit comments

Comments
 (0)