Skip to content

Commit f329831

Browse files
committed
fix(core): handle pointer capture for selection on drag (#1543)
* fix(core): handle pointer capture for selection on drag * chore(changeset): add
1 parent 180109c commit f329831

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/tiny-peaches-dance.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+
Handle pointer capture for selection on drag

packages/core/src/container/Pane/Pane.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function onWheel(event: WheelEvent) {
114114
115115
function onPointerDown(event: PointerEvent) {
116116
containerBounds.value = vueFlowRef.value?.getBoundingClientRect()
117-
container.value?.setPointerCapture(event.pointerId)
117+
;(event.target as Element)?.setPointerCapture?.(event.pointerId)
118118
119119
if (
120120
!elementsSelectable.value ||
@@ -147,6 +147,7 @@ function onPointerDown(event: PointerEvent) {
147147
}
148148
149149
userSelectionActive.value = true
150+
nodesSelectionActive.value = false
150151
151152
emits.selectionStart(event)
152153
}
@@ -215,15 +216,17 @@ function onPointerUp(event: PointerEvent) {
215216
return
216217
}
217218
218-
container.value?.releasePointerCapture(event.pointerId)
219+
;(event.target as Element)?.releasePointerCapture(event.pointerId)
219220
220221
// We only want to trigger click functions when in selection mode if
221222
// the user did not move the mouse.
222223
if (!userSelectionActive.value && userSelectionRect.value && event.target === container.value) {
223224
onClick(event)
224225
}
225226
226-
nodesSelectionActive.value = prevSelectedNodesCount.value > 0
227+
if (prevSelectedNodesCount.value > 0) {
228+
nodesSelectionActive.value = true
229+
}
227230
228231
resetUserSelection()
229232

0 commit comments

Comments
 (0)