fix a bug where too many adder nodes are added (#1499)
This commit is contained in:
@@ -583,16 +583,14 @@ function getElements(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
const children = data.filter((b) => b.parentId === block.id);
|
const children = data.filter((b) => b.parentId === block.id);
|
||||||
|
const adderNodeId = nanoid();
|
||||||
if (children.length === 0) {
|
if (children.length === 0) {
|
||||||
const adderNodeId = nanoid();
|
|
||||||
nodes.push(nodeAdderNode(adderNodeId, block.id));
|
|
||||||
edges.push(defaultEdge(startNodeId, adderNodeId));
|
edges.push(defaultEdge(startNodeId, adderNodeId));
|
||||||
} else {
|
} else {
|
||||||
const firstChild = children.find((c) => c.previous === null)!;
|
const firstChild = children.find((c) => c.previous === null)!;
|
||||||
edges.push(edgeWithAddButton(startNodeId, firstChild.id));
|
edges.push(edgeWithAddButton(startNodeId, firstChild.id));
|
||||||
}
|
}
|
||||||
const lastChild = children.find((c) => c.next === null);
|
const lastChild = children.find((c) => c.next === null);
|
||||||
const adderNodeId = nanoid();
|
|
||||||
nodes.push(nodeAdderNode(adderNodeId, block.id));
|
nodes.push(nodeAdderNode(adderNodeId, block.id));
|
||||||
if (lastChild) {
|
if (lastChild) {
|
||||||
edges.push(defaultEdge(lastChild.id, adderNodeId));
|
edges.push(defaultEdge(lastChild.id, adderNodeId));
|
||||||
|
|||||||
Reference in New Issue
Block a user