Skip to content

Commit

Permalink
fix: fix a few undefined cases in our vendored tidy.ts
Browse files Browse the repository at this point in the history
This is just an expedient fix. A proper fix is tracked in:

#1189

Signed-off-by: Drew Hess <[email protected]>
  • Loading branch information
dhess committed May 4, 2024
1 parent 660f8ff commit 6fdd8e1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/TreeReactFlow/tidy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,18 @@ export class TidyLayout extends Disposable {
this.tidy.layout();
const positions = this.tidy.get_pos();
for (let i = 0; i < positions.length; i += 3) {
const id = positions[i] | 0;
// Better error handling needed here when the id is undefined.
//
// https://github.com/hackworthltd/primer-app/issues/1189
const id = positions[i] || 0;
const node = this.idToNode.get(id)!;
node.x = positions[i + 1];
node.y = positions[i + 2];

// Also need better error handling here when the node's x or y
// position is undefined.
//
// https://github.com/hackworthltd/primer-app/issues/1189
node.x = positions[i + 1] || 0;
node.y = positions[i + 2] || 0;
}
}

Expand Down

0 comments on commit 6fdd8e1

Please sign in to comment.