Skip to content

Commit 2201cdd

Browse files
authored
refactor(core): allow passing null/undefined to use node connection args (#1820)
* refactor(core): allow passing null/undefined to use node connection args Signed-off-by: braks <[email protected]> * chore(core): cleanup Signed-off-by: braks <[email protected]> * chore(changeset): add --------- Signed-off-by: braks <[email protected]>
1 parent 0cc4c99 commit 2201cdd

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.changeset/shiny-pots-wash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": minor
3+
---
4+
5+
Allow passing null or undefined to `useNodeConnections` options

packages/core/src/composables/useNodeConnections.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { useNodeId } from './useNodeId'
66
import { useVueFlow } from './useVueFlow'
77

88
export interface UseNodeConnectionsParams {
9-
handleType?: MaybeRefOrGetter<HandleType>
10-
handleId?: MaybeRefOrGetter<string | null>
11-
nodeId?: MaybeRefOrGetter<string | null>
9+
handleType?: MaybeRefOrGetter<HandleType | null | undefined>
10+
handleId?: MaybeRefOrGetter<string | null | undefined>
11+
nodeId?: MaybeRefOrGetter<string | null | undefined>
1212
onConnect?: (connections: NodeConnection[]) => void
1313
onDisconnect?: (connections: NodeConnection[]) => void
1414
}
@@ -42,9 +42,12 @@ export function useNodeConnections(params: UseNodeConnectionsParams = {}) {
4242
const currentHandleType = toValue(handleType)
4343
const currHandleId = toValue(handleId)
4444

45-
return `${currNodeId}${
46-
currentHandleType ? (currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}`) : ''
47-
}`
45+
let handleSuffix = ''
46+
if (currentHandleType) {
47+
handleSuffix = currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}`
48+
}
49+
50+
return `${currNodeId}${handleSuffix}`
4851
})
4952

5053
watch(

0 commit comments

Comments
 (0)