diff --git a/packages/client/src/components/app/container/GridContainer.svelte b/packages/client/src/components/app/container/GridContainer.svelte index d97e7ceafb..0f51c209ce 100644 --- a/packages/client/src/components/app/container/GridContainer.svelte +++ b/packages/client/src/components/app/container/GridContainer.svelte @@ -53,42 +53,40 @@ onMount(() => { let observer - if ($builderStore.inBuilder) { - // Set up an observer to watch for changes in metadata attributes of child - // components, as well as child addition and deletion - observer = new MutationObserver(mutations => { - for (let mutation of mutations) { - const { target, type, addedNodes, removedNodes } = mutation - if (target === ref) { - if (addedNodes[0]?.classList?.contains("component")) { - // We've added a new child component inside the grid, so we need - // to consider it when determining required rows - storeChild(addedNodes[0]) - } else if (removedNodes[0]?.classList?.contains("component")) { - // We've removed a child component inside the grid, so we need - // to stop considering it when determining required rows - removeChild(removedNodes[0]) - } - } else if ( - type === "attributes" && - target.parentNode === ref && - target.classList.contains("component") - ) { - // We've updated the size or position of a child - storeChild(target) + // Set up an observer to watch for changes in metadata attributes of child + // components, as well as child addition and deletion + observer = new MutationObserver(mutations => { + for (let mutation of mutations) { + const { target, type, addedNodes, removedNodes } = mutation + if (target === ref) { + if (addedNodes[0]?.classList?.contains("component")) { + // We've added a new child component inside the grid, so we need + // to consider it when determining required rows + storeChild(addedNodes[0]) + } else if (removedNodes[0]?.classList?.contains("component")) { + // We've removed a child component inside the grid, so we need + // to stop considering it when determining required rows + removeChild(removedNodes[0]) } + } else if ( + type === "attributes" && + target.parentNode === ref && + target.classList.contains("component") + ) { + // We've updated the size or position of a child + storeChild(target) } - }) - observer.observe(ref, { - childList: true, - attributes: true, - subtree: true, - attributeFilter: [ - "data-grid-desktop-row-end", - "data-grid-mobile-row-end", - ], - }) - } + } + }) + observer.observe(ref, { + childList: true, + attributes: true, + subtree: true, + attributeFilter: [ + "data-grid-desktop-row-end", + "data-grid-mobile-row-end", + ], + }) // Now that the observer is set up, we mark the grid as mounted to mount // our child components @@ -138,26 +136,11 @@