diff --git a/.changeset/tall-onions-guess.md b/.changeset/tall-onions-guess.md new file mode 100644 index 00000000..451a5a6c --- /dev/null +++ b/.changeset/tall-onions-guess.md @@ -0,0 +1,5 @@ +--- +'@xyflow/system': patch +--- + +chore(subflows): log warning instead of throwing an error when parent node cant be found diff --git a/packages/system/src/utils/store.ts b/packages/system/src/utils/store.ts index c800c90b..f2cf1bfd 100644 --- a/packages/system/src/utils/store.ts +++ b/packages/system/src/utils/store.ts @@ -105,8 +105,12 @@ function updateChildPosition( const parentId = node.parentId!; const parentNode = nodeLookup.get(parentId); + if (!parentNode) { - throw new Error(`Parent node ${parentId} not found`); + console.warn( + `Parent node ${parentId} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.` + ); + return; } // update the parentLookup