From 7a09afa12acab084d849c7134fcbbb1367ff456d Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:54:55 +0200 Subject: [PATCH] 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 <78412429+bcakmakoglu@users.noreply.github.com> * chore(core): cleanup Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --- .changeset/shiny-pots-wash.md | 5 +++++ .../core/src/composables/useNodeConnections.ts | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .changeset/shiny-pots-wash.md diff --git a/.changeset/shiny-pots-wash.md b/.changeset/shiny-pots-wash.md new file mode 100644 index 00000000..12b7e53d --- /dev/null +++ b/.changeset/shiny-pots-wash.md @@ -0,0 +1,5 @@ +--- +"@vue-flow/core": minor +--- + +Allow passing null or undefined to `useNodeConnections` options diff --git a/packages/core/src/composables/useNodeConnections.ts b/packages/core/src/composables/useNodeConnections.ts index 1f1bffbe..2df2822c 100644 --- a/packages/core/src/composables/useNodeConnections.ts +++ b/packages/core/src/composables/useNodeConnections.ts @@ -6,9 +6,9 @@ import { useNodeId } from './useNodeId' import { useVueFlow } from './useVueFlow' export interface UseNodeConnectionsParams { - handleType?: MaybeRefOrGetter - handleId?: MaybeRefOrGetter - nodeId?: MaybeRefOrGetter + handleType?: MaybeRefOrGetter + handleId?: MaybeRefOrGetter + nodeId?: MaybeRefOrGetter onConnect?: (connections: NodeConnection[]) => void onDisconnect?: (connections: NodeConnection[]) => void } @@ -42,9 +42,12 @@ export function useNodeConnections(params: UseNodeConnectionsParams = {}) { const currentHandleType = toValue(handleType) const currHandleId = toValue(handleId) - return `${currNodeId}${ - currentHandleType ? (currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}`) : '' - }` + let handleSuffix = '' + if (currentHandleType) { + handleSuffix = currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}` + } + + return `${currNodeId}${handleSuffix}` }) watch(