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>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@vue-flow/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent drag-click handler when multi selection is active.
|
||||||
@@ -229,24 +229,14 @@ export function useDrag(params: UseDragParams) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const eventEnd = (event: UseDragEvent) => {
|
const eventEnd = (event: UseDragEvent) => {
|
||||||
if (!dragStarted) {
|
if (!dragging.value && !multiSelectionActive.value) {
|
||||||
const pointerPos = getPointerPosition(event)
|
onClick?.(event.sourceEvent)
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dragging.value = false
|
dragging.value = false
|
||||||
autoPanStarted = false
|
autoPanStarted = false
|
||||||
dragStarted = false
|
dragStarted = false
|
||||||
|
lastPos = { x: undefined, y: undefined }
|
||||||
|
|
||||||
cancelAnimationFrame(autoPanId)
|
cancelAnimationFrame(autoPanId)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user