From 3fc9fbfd39ba4ddb0125609339f30b2c17a27f58 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Mon, 6 Jul 2020 11:17:54 +0100 Subject: [PATCH] bugfix: delete component sometimes breaks navigation --- .../frontend/[page]/[screen]/_layout.svelte | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/pages/[application]/frontend/[page]/[screen]/_layout.svelte b/packages/builder/src/pages/[application]/frontend/[page]/[screen]/_layout.svelte index b9bed2866a..b601251b16 100644 --- a/packages/builder/src/pages/[application]/frontend/[page]/[screen]/_layout.svelte +++ b/packages/builder/src/pages/[application]/frontend/[page]/[screen]/_layout.svelte @@ -38,15 +38,21 @@ // Loop through each ID ids.forEach(id => { - // Find ID and select it - componentToSelect = currentChildren.find(child => child._id === id) + // Find ID + const component = currentChildren.find(child => child._id === id) + + // If it does not exist, ignore (use last valid route) + if (!component) return + + componentToSelect = component // Update childrens array to selected components children currentChildren = componentToSelect._children }) // Select Component! - store.selectComponent(componentToSelect) + if (componentToSelect) + store.selectComponent(componentToSelect) }