From 5ba0a10e9981d0f7a6b971a045aba0e8dcd1ff5f Mon Sep 17 00:00:00 2001 From: Nina Doschek Date: Wed, 21 Feb 2024 15:23:28 +0100 Subject: [PATCH] GLSP-1266 Fix handling of zero values in GBoundsAwareBuilder functions Resolves GH-1266 --- packages/graph/src/gbounds-aware.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/graph/src/gbounds-aware.ts b/packages/graph/src/gbounds-aware.ts index bec116a..ba992bb 100644 --- a/packages/graph/src/gbounds-aware.ts +++ b/packages/graph/src/gbounds-aware.ts @@ -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; } @@ -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; }