diff --git a/packages/core/src/composables/useZoomPanHelper.ts b/packages/core/src/composables/useZoomPanHelper.ts index dc09cb85..d8c566b6 100644 --- a/packages/core/src/composables/useZoomPanHelper.ts +++ b/packages/core/src/composables/useZoomPanHelper.ts @@ -107,13 +107,10 @@ export default (vueFlowId?: string): ViewportFunctions => { if (!getNodes.length) return - let nodeBounds: GraphNode[] = [] - if (options.nodes) { - nodeBounds = nodes.filter((n) => options.nodes?.includes(n.id)) - } + let nodeBounds: GraphNode[] = options.includeHiddenNodes ? nodes.filter((n) => n.width && n.height) : getNodes - if (!nodeBounds || !nodeBounds.length) { - nodeBounds = options.includeHiddenNodes ? nodeBounds : getNodes + if (options.nodes) { + nodeBounds = nodeBounds.filter((n) => options.nodes?.includes(n.id)) } const bounds = getRectOfNodes(nodeBounds)