Skip to content

Commit 6880409

Browse files
authored
refactor(core): use event target for Handle pointer down events (#1924)
* refactor(core): use event target for Handle pointer down events Signed-off-by: braks <[email protected]> * chore(changeset): add --------- Signed-off-by: braks <[email protected]>
1 parent 957d011 commit 6880409

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/rude-suns-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": minor
3+
---
4+
5+
Use event target for `<Handle>` components to determine the "clicked" handle, avoiding calls to `getElementFromPoint and allowing "detached" handles

packages/core/src/composables/useHandle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ export function useHandle({
8585

8686
// when vue-flow is used inside a shadow root we can't use document
8787
const doc = getHostForElement(event.target as HTMLElement)
88+
const clickedHandle = event.currentTarget as HTMLElement | null
8889

89-
if ((isMouseTriggered && event.button === 0) || !isMouseTriggered) {
90+
if (clickedHandle && ((isMouseTriggered && event.button === 0) || !isMouseTriggered)) {
9091
const node = findNode(toValue(nodeId))
9192

9293
let isValidConnectionHandler = toValue(isValidConnection) || isValidConnectionProp.value || alwaysValid
@@ -100,7 +101,6 @@ export function useHandle({
100101
let autoPanId = 0
101102

102103
const { x, y } = getEventPosition(event)
103-
const clickedHandle = doc?.elementFromPoint(x, y)
104104
const handleType = getHandleType(toValue(edgeUpdaterType), clickedHandle)
105105
const containerBounds = vueFlowRef.value?.getBoundingClientRect()
106106

0 commit comments

Comments
 (0)