From aae3f49eec34633f7fb977e83b46057f8407c22f Mon Sep 17 00:00:00 2001 From: peterkogo Date: Tue, 1 Apr 2025 12:39:42 +0200 Subject: [PATCH] make fitView fire even when onNodesChange is not implmented --- packages/react/src/components/BatchProvider/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react/src/components/BatchProvider/index.tsx b/packages/react/src/components/BatchProvider/index.tsx index 382324da..f41b79a8 100644 --- a/packages/react/src/components/BatchProvider/index.tsx +++ b/packages/react/src/components/BatchProvider/index.tsx @@ -42,13 +42,16 @@ export function BatchProvider[]; + + // We only want to fire onNodesChange if there are changes to the nodes if (changes.length > 0) { - onNodesChange(changes); + onNodesChange?.(changes); } else if (fitViewQueued) { // If there are no changes to the nodes, we still need to call setNodes // to trigger a re-render and fitView. @@ -61,6 +64,7 @@ export function BatchProvider(nodeQueueHandler); const edgeQueueHandler = useCallback((queueItems: QueueItem[]) => {