Skip to content

Commit 660831c

Browse files
committed
refactor(core): check if starting handle exists
1 parent 688f886 commit 660831c

File tree

1 file changed

+4
-3
lines changed
  • packages/core/src/components/ConnectionLine

1 file changed

+4
-3
lines changed

packages/core/src/components/ConnectionLine/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ const ConnectionLine = defineComponent({
4545
return null
4646
}
4747

48-
const handleId = connectionStartHandle.value.handleId
48+
const startHandleId = connectionStartHandle.value.handleId
4949

5050
const handleType = connectionStartHandle.value.type
5151

52-
const targetNode = (connectionEndHandle.value?.handleId && findNode(connectionEndHandle.value.nodeId)) || null
52+
const targetNode = (connectionEndHandle.value && findNode(connectionEndHandle.value.nodeId)) || null
5353

5454
const toX = (connectionPosition.value.x - viewport.value.x) / viewport.value.zoom
5555
const toY = (connectionPosition.value.y - viewport.value.y) / viewport.value.zoom
@@ -65,14 +65,15 @@ const ConnectionLine = defineComponent({
6565
return null
6666
}
6767

68-
const fromHandle = (handleId ? handleBounds.find((d) => d.id === handleId) : handleBounds[0]) ?? null
68+
const fromHandle = (startHandleId ? handleBounds.find((d) => d.id === startHandleId) : handleBounds[0]) ?? null
6969
const fromPosition = fromHandle?.position || Position.Top
7070
const { x: fromX, y: fromY } = getHandlePosition(
7171
fromPosition,
7272
{ ...fromNode.dimensions, ...fromNode.computedPosition },
7373
fromHandle,
7474
)
7575

76+
// todo: this is a bit of a mess, we should refactor this
7677
const toHandle =
7778
(targetNode &&
7879
connectionEndHandle.value?.handleId &&

0 commit comments

Comments
 (0)