diff --git a/example/src/Layouting/index.tsx b/example/src/Layouting/index.tsx
index 88170feb..8e4ce5bf 100644
--- a/example/src/Layouting/index.tsx
+++ b/example/src/Layouting/index.tsx
@@ -59,6 +59,10 @@ const LayoutFlow = () => {
setNodes(layoutedNodes);
};
+ const unselect = () => {
+ setNodes((nds) => nds.map((n) => ({ ...n, selected: false })));
+ };
+
return (
@@ -77,7 +81,10 @@ const LayoutFlow = () => {
-
+
+
diff --git a/src/utils/graph.ts b/src/utils/graph.ts
index 37765a01..a426baed 100644
--- a/src/utils/graph.ts
+++ b/src/utils/graph.ts
@@ -141,6 +141,10 @@ export const pointToRendererPoint = (
};
export const getRectOfNodes = (nodes: Node[]): Rect => {
+ if (nodes.length === 0) {
+ return { x: 0, y: 0, width: 0, height: 0 };
+ }
+
const box = nodes.reduce(
(currBox, { positionAbsolute, position, width, height }) =>
getBoundsOfBoxes(