fix(fitView): handle uncontrolled flows

This commit is contained in:
moklick
2025-03-27 13:17:46 +01:00
parent afbd4ac6a6
commit 77b24e7f3a
+3 -2
View File
@@ -45,7 +45,7 @@ const createStore = ({
async function resolveFitView() { async function resolveFitView() {
const { nodeLookup, panZoom, fitViewOptions, fitViewResolver, width, height, minZoom, maxZoom } = get(); const { nodeLookup, panZoom, fitViewOptions, fitViewResolver, width, height, minZoom, maxZoom } = get();
if (!panZoom || !fitViewResolver) { if (!panZoom) {
return; return;
} }
@@ -61,7 +61,7 @@ const createStore = ({
fitViewOptions fitViewOptions
); );
fitViewResolver.resolve(true); fitViewResolver?.resolve(true);
/** /**
* wait for the fitViewport to resolve before deleting the resolver, * wait for the fitViewport to resolve before deleting the resolver,
* we want to reuse the old resolver if the user calls fitView again in the mean time * we want to reuse the old resolver if the user calls fitView again in the mean time
@@ -89,6 +89,7 @@ const createStore = ({
checkEquality: true, checkEquality: true,
}); });
console.log(fitViewQueued, nodesInitialized);
if (fitViewQueued && nodesInitialized) { if (fitViewQueued && nodesInitialized) {
resolveFitView(); resolveFitView();
set({ nodes, fitViewQueued: false, fitViewOptions: undefined }); set({ nodes, fitViewQueued: false, fitViewOptions: undefined });