Skip to content

Commit

Permalink
fix(core): handle pointer capture for selection on drag (#1543)
Browse files Browse the repository at this point in the history
* fix(core): handle pointer capture for selection on drag

* chore(changeset): add
  • Loading branch information
bcakmakoglu authored Jul 15, 2024
1 parent de75620 commit 85c8d2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-peaches-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vue-flow/core": patch
---

Handle pointer capture for selection on drag
9 changes: 6 additions & 3 deletions packages/core/src/container/Pane/Pane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function onWheel(event: WheelEvent) {
function onPointerDown(event: PointerEvent) {
containerBounds.value = vueFlowRef.value?.getBoundingClientRect()
container.value?.setPointerCapture(event.pointerId)
;(event.target as Element)?.setPointerCapture?.(event.pointerId)
if (
!elementsSelectable.value ||
Expand Down Expand Up @@ -147,6 +147,7 @@ function onPointerDown(event: PointerEvent) {
}
userSelectionActive.value = true
nodesSelectionActive.value = false
emits.selectionStart(event)
}
Expand Down Expand Up @@ -215,15 +216,17 @@ function onPointerUp(event: PointerEvent) {
return
}
container.value?.releasePointerCapture(event.pointerId)
;(event.target as Element)?.releasePointerCapture(event.pointerId)
// We only want to trigger click functions when in selection mode if
// the user did not move the mouse.
if (!userSelectionActive.value && userSelectionRect.value && event.target === container.value) {
onClick(event)
}
nodesSelectionActive.value = prevSelectedNodesCount.value > 0
if (prevSelectedNodesCount.value > 0) {
nodesSelectionActive.value = true
}
resetUserSelection()
Expand Down

0 comments on commit 85c8d2d

Please sign in to comment.