Skip to content

Commit 7161e9e

Browse files
committed
refactor(core): allow null instead of undefined as id for useHandleConnections
1 parent f4fb4d8 commit 7161e9e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/core/src/composables/useHandleConnections.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { useVueFlow } from './useVueFlow'
99

1010
interface UseHandleConnectionsParams {
1111
type: MaybeRefOrGetter<HandleType>
12-
id?: MaybeRefOrGetter<string | undefined>
13-
nodeId?: MaybeRefOrGetter<string | undefined>
12+
id?: MaybeRefOrGetter<string | null>
13+
nodeId?: MaybeRefOrGetter<string | null>
1414
onConnect?: (connections: Connection[]) => void
1515
onDisconnect?: (connections: Connection[]) => void
1616
}
@@ -35,13 +35,19 @@ export function useHandleConnections({
3535
onDisconnect,
3636
}: UseHandleConnectionsParams): ComputedRef<Connection[]> {
3737
const { connectionLookup } = useVueFlow()
38+
3839
const _nodeId = useNodeId()
39-
const currentNodeId = toRef(() => toValue(nodeId) || _nodeId)
40+
41+
const currentNodeId = toRef(() => toValue(nodeId) ?? _nodeId)
42+
43+
const handleType = toRef(() => toValue(type))
44+
45+
const handleId = toRef(() => toValue(id) ?? null)
4046

4147
const connections = ref<Map<string, Connection>>()
4248

4349
watch(
44-
() => connectionLookup.value.get(`${currentNodeId.value}-${toValue(type)}-${toValue(id)}`),
50+
() => connectionLookup.value.get(`${currentNodeId.value}-${handleType.value}-${handleId.value}`),
4551
(nextConnections) => {
4652
if (areConnectionMapsEqual(connections.value, nextConnections)) {
4753
return

0 commit comments

Comments
 (0)