Skip to content

Commit 9d1f5fa

Browse files
committed
fix(core): check if viewport is defined before setting
1 parent cfbc4d2 commit 9d1f5fa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/core/src/store/actions.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,14 +844,18 @@ export function useActions(
844844
setEdges(edges)
845845
}
846846

847-
if (viewport || position) {
847+
if ((viewport?.x && viewport?.y) || position) {
848+
const x = viewport?.x || position[0]
849+
const y = viewport?.y || position[1]
850+
const nextZoom = viewport?.zoom || zoom || state.viewport.zoom
851+
848852
until(() => viewportHelper.value.initialized)
849853
.toBe(true)
850854
.then(() => {
851855
viewportHelper.value.setViewport({
852-
x: viewport.x || position[0],
853-
y: viewport.y || position[1],
854-
zoom: viewport.zoom || zoom || state.viewport.zoom,
856+
x,
857+
y,
858+
zoom: nextZoom,
855859
})
856860
})
857861
}

0 commit comments

Comments
 (0)