Skip to content

Commit 2556fe7

Browse files
committed
fix(docs): connect preview edges to subflow container handles
toReactFlowElements hardcoded targetHandle to 'target' and defaulted source handles to 'source', but Loop/Parallel containers (SubflowNodeView) expose a 'loop-end-source'/'parallel-end-source' output handle and a left input handle with no id. Edges into and out of containers therefore failed to connect. Resolve each edge end to the block's real handle based on whether it's a container.
1 parent d9d1bfe commit 2556fe7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

apps/docs/components/workflow-preview/workflow-data.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ export function toReactFlowElements(
121121
const isEdgeHighlight = highlightEdge === e.id
122122
const dimmed = hasHighlight && !isEdgeHighlight
123123
const isErrorEdge = e.sourceHandle === 'error'
124+
// Subflow containers expose a right-edge output handle (`loop-end-source` /
125+
// `parallel-end-source`) and a left-edge input handle with no id; regular
126+
// blocks use `source` / `target`. Resolve each end to the block's real handle
127+
// so edges into and out of Loop/Parallel containers still connect.
128+
const sourceBlock = blocksById.get(e.source)
129+
const targetBlock = blocksById.get(e.target)
130+
const sourceHandle =
131+
e.sourceHandle ?? (sourceBlock?.size ? `${sourceBlock.type}-end-source` : 'source')
132+
const targetHandle = targetBlock?.size ? undefined : 'target'
124133
return {
125134
id: e.id,
126135
source: e.source,
@@ -131,8 +140,8 @@ export function toReactFlowElements(
131140
...(isEdgeHighlight ? EDGE_STYLE_HIGHLIGHT : isErrorEdge ? EDGE_STYLE_ERROR : EDGE_STYLE),
132141
opacity: dimmed ? 0.35 : 1,
133142
},
134-
sourceHandle: e.sourceHandle ?? 'source',
135-
targetHandle: 'target',
143+
sourceHandle,
144+
targetHandle,
136145
data: {
137146
animate,
138147
delay: animate ? sourceIndex * BLOCK_STAGGER + BLOCK_STAGGER : 0,

0 commit comments

Comments
 (0)