Skip to content

Commit

Permalink
GLSP-1266 Fix handling of zero values in GBoundsAwareBuilder functions
Browse files Browse the repository at this point in the history
Resolves GH-1266
  • Loading branch information
ndoschek committed Feb 21, 2024
1 parent 18dbe1a commit 5ba0a10
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/graph/src/gbounds-aware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ export namespace GBoundsAwareBuilder {
const proxy = builder['proxy'];
if (typeof pointOrX === 'object') {
proxy.position = pointOrX;
} else if (y) {
} else if (y !== undefined) {
proxy.position = { x: pointOrX, y };
} else {
// Optionally handle cases where y is not provided
proxy.position = { x: pointOrX, y: 0 };
console.warn(
`Incomplete parameters for GBoundsAwareBuilder.position function. Setting position to ${JSON.stringify(proxy.position)}`
);
}
return builder;
}
Expand All @@ -45,8 +51,12 @@ export namespace GBoundsAwareBuilder {
const proxy = builder['proxy'];
if (typeof sizeOrWidth === 'object') {
proxy.size = sizeOrWidth;
} else if (height) {
} else if (height !== undefined) {
proxy.size = { width: sizeOrWidth, height };
} else {
// Optionally handle cases where height is not provided
proxy.size = { width: sizeOrWidth, height: 0 };
console.warn(`Incomplete parameters for GBoundsAwareBuilder.size function. Setting size to ${JSON.stringify(proxy.size)}`);
}
return builder;
}
Expand Down

0 comments on commit 5ba0a10

Please sign in to comment.