Skip to content

Commit

Permalink
fix: Use non-empty edge IDs in React Flow trees
Browse files Browse the repository at this point in the history
  • Loading branch information
georgefst authored and dhess committed Jun 2, 2022
1 parent d147412 commit 255d6ce
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/primer-components/src/TreeReactFlow/TreeReactFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ const convertTree = (
data: { label: tree.label },
position: { x, y },
};
const thisToChildren: Edge[] = tree.childTrees.map((t) => ({
id: "",
source: id,
target: t.nodeId.toString(),
}));
const thisToChildren: Edge[] = tree.childTrees.map((t) => {
const target = t.nodeId.toString();
return {
id: JSON.stringify([id, target]),
source: id,
target,
};
});
return {
nodes: [thisNode, ...children.flatMap(({ nodes }) => nodes)],
edges: [...thisToChildren, ...children.flatMap(({ edges }) => edges)],
Expand Down

0 comments on commit 255d6ce

Please sign in to comment.