From 43e06954161d275bdf905c7dac07a66eef8180e6 Mon Sep 17 00:00:00 2001 From: Alessandro Date: Tue, 14 Oct 2025 13:33:58 +0200 Subject: [PATCH] restore version with infinity --- packages/system/src/utils/graph.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/system/src/utils/graph.ts b/packages/system/src/utils/graph.ts index ab68ae72..1b7d27d1 100644 --- a/packages/system/src/utils/graph.ts +++ b/packages/system/src/utils/graph.ts @@ -241,16 +241,25 @@ export const getInternalNodesBounds = , params: GetInternalNodesBoundsParams = {} ): Rect => { - let box = { x: 0, y: 0, x2: 0, y2: 0 }; + const emptyRect = { x: 0, y: 0, width: 0, height: 0 }; + + if (nodeLookup.size === 0) { + return emptyRect; + } + + let box = { x: Infinity, y: Infinity, x2: -Infinity, y2: -Infinity }; + + let hasVisibleNodes = false; nodeLookup.forEach((node) => { if (params.filter === undefined || params.filter(node)) { + hasVisibleNodes = true; const nodeBox = nodeToBox(node as InternalNodeBase); box = getBoundsOfBoxes(box, nodeBox); } }); - return boxToRect(box); + return hasVisibleNodes ? boxToRect(box) : emptyRect; }; export const getNodesInside = (