From cf308bac9459241f6e5af5513b6986859400e616 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 23 Nov 2022 12:33:31 +0000 Subject: [PATCH] Fix crash when deleting a selected side panel component --- .../src/components/app/SidePanel.svelte | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/client/src/components/app/SidePanel.svelte b/packages/client/src/components/app/SidePanel.svelte index 9e905203c0..a48b8365a3 100644 --- a/packages/client/src/components/app/SidePanel.svelte +++ b/packages/client/src/components/app/SidePanel.svelte @@ -28,40 +28,32 @@ $: open = $sidePanelStore.contentId === $component.id const showInSidePanel = (el, visible) => { - const target = document.getElementById("side-panel-container") - const node = el.parentNode - const destroy = () => { - if (target.contains(node)) { - target.removeChild(node) - } - } const update = visible => { + const target = document.getElementById("side-panel-container") + const node = el if (visible) { if (!target.contains(node)) { target.appendChild(node) } - el.hidden = false } else { - destroy() - el.hidden = true + if (target.contains(node)) { + target.removeChild(node) + } } } // Apply initial visibility update(visible) - return { - update, - destroy, - } + return { update } } @@ -69,12 +61,15 @@