From 011ba2676945a618090ee7166098c01887416169 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 14 Oct 2022 19:34:23 +0100 Subject: [PATCH] Fix DND not working in field groups and any other component where children are not rendered inside the first DOM node --- packages/client/src/components/preview/DNDHandler.svelte | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/client/src/components/preview/DNDHandler.svelte b/packages/client/src/components/preview/DNDHandler.svelte index 61b34eefd3..a9c52f0099 100644 --- a/packages/client/src/components/preview/DNDHandler.svelte +++ b/packages/client/src/components/preview/DNDHandler.svelte @@ -123,6 +123,14 @@ return } + // As the first DOM node in a component may not necessarily contain the + // child components, we can find to try the parent of the first child + // component and use that as the real parent DOM node + const childNode = node.getElementsByClassName("component")[0] + if (childNode?.parentNode) { + node = childNode.parentNode + } + // Append an ephemeral div to allow us to determine layout if only one // child exists let ephemeralDiv