Skip to content

Commit

Permalink
Fix a bug where adder node wasnt added to loop children (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy authored Sep 16, 2024
1 parent e280e9a commit 6f0d899
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,32 @@ function getElements(blocks: Array<WorkflowBlock>): {
}
});

const loopBlocks = data.filter((d) => d.block.block_type === "for_loop");
loopBlocks.forEach((block) => {
const children = data.filter((b) => b.parentId === block.id);
const lastChild = children.find((c) => c.next === null);
nodes.push({
id: `${block.id}-nodeAdder`,
type: "nodeAdder",
position: { x: 0, y: 0 },
data: {},
draggable: false,
connectable: false,
parentId: block.id,
});
if (lastChild) {
edges.push({
id: `${block.id}-nodeAdder-edge`,
type: "default",
source: lastChild.id,
target: `${block.id}-nodeAdder`,
style: {
strokeWidth: 2,
},
});
}
});

if (nodes.length > 0) {
const lastNode = data.find((d) => d.next === null && d.parentId === null);
edges.push({
Expand Down

0 comments on commit 6f0d899

Please sign in to comment.