Skip to content

Commit

Permalink
fix a bug where too many adder nodes are added (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
wintonzheng authored Jan 6, 2025
1 parent d6ff0ec commit 75002c0
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,14 @@ function getElements(
),
);
const children = data.filter((b) => b.parentId === block.id);
const adderNodeId = nanoid();
if (children.length === 0) {
const adderNodeId = nanoid();
nodes.push(nodeAdderNode(adderNodeId, block.id));
edges.push(defaultEdge(startNodeId, adderNodeId));
} else {
const firstChild = children.find((c) => c.previous === null)!;
edges.push(edgeWithAddButton(startNodeId, firstChild.id));
}
const lastChild = children.find((c) => c.next === null);
const adderNodeId = nanoid();
nodes.push(nodeAdderNode(adderNodeId, block.id));
if (lastChild) {
edges.push(defaultEdge(lastChild.id, adderNodeId));
Expand Down

0 comments on commit 75002c0

Please sign in to comment.