Skip to content

Commit 6e2c3e5

Browse files
committed
fix(core): use validator with null handle when no closest can be found
1 parent b017139 commit 6e2c3e5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

packages/core/src/utils/handle.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function getClosestHandle(
6666
pos: XYPosition,
6767
connectionRadius: number,
6868
handles: ConnectionHandle[],
69-
validator: (handle: ConnectionHandle) => ValidHandleResult,
69+
validator: (handle: ConnectionHandle | null) => ValidHandleResult,
7070
) {
7171
let closestHandles: { handle: ConnectionHandle; validHandleResult: ValidHandleResult }[] = []
7272
let minDistance = Infinity
@@ -94,7 +94,7 @@ export function getClosestHandle(
9494
})
9595

9696
if (!closestHandles.length) {
97-
return { handle: null, validHandleResult: defaultValidHandleResult() }
97+
return { handle: null, validHandleResult: validator(null) }
9898
}
9999

100100
return closestHandles.length === 1
@@ -126,10 +126,7 @@ export function isValidHandle(
126126
// because it could be that the center of another handle is closer to the mouse pointer than the handle below the cursor
127127
const handleToCheck = handleBelow?.classList.contains('vue-flow__handle') ? handleBelow : handleDomNode
128128

129-
const result = {
130-
...defaultValidHandleResult(),
131-
handleDomNode: handleToCheck,
132-
}
129+
const result = defaultValidHandleResult()
133130

134131
if (handleToCheck) {
135132
const handleType = getHandleType(undefined, handleToCheck)

0 commit comments

Comments
 (0)