From 1f1674229c5c5f547138f65a41c8f9a94b88fcb9 Mon Sep 17 00:00:00 2001 From: Joel Schneider Date: Fri, 24 Apr 2020 07:13:13 -0400 Subject: [PATCH] Deep clone data nodes Otherwise immer will mutate the object as we remove nodes --- packages/core/src/editor/actions.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/editor/actions.ts b/packages/core/src/editor/actions.ts index 2159ee800..82a8ddd75 100644 --- a/packages/core/src/editor/actions.ts +++ b/packages/core/src/editor/actions.ts @@ -169,9 +169,11 @@ export const Actions = ( !query.node(targetNode.id).isTopLevelCanvas(), "Cannot delete a Canvas that is not a direct child of another Canvas" ); - targetNode.data.nodes!.forEach((childId) => { - _("delete")(childId); - }); + if (targetNode.data.nodes) { + [...targetNode.data.nodes].forEach((childId) => { + _("delete")(childId); + }); + } } const parentNode = state.nodes[targetNode.data.parent],