From e19d17c4f52565caf6345fbe210f126661a11f64 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 20 Sep 2021 09:12:35 +0100 Subject: [PATCH] Prevent DND targetting either above or below the screen/layout, and fix bug determinging whether a drop target is valid --- packages/client/src/components/Component.svelte | 2 +- packages/client/src/components/preview/DNDHandler.svelte | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index 6192004b42..5e02e345d4 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -174,7 +174,7 @@ // Drag and drop helper tags $: draggable = interactive && !isLayout && !isScreen - $: droppable = interactive + $: droppable = interactive && !isLayout && !isScreen $: dropInside = interactive && definition?.hasChildren && !children.length diff --git a/packages/client/src/components/preview/DNDHandler.svelte b/packages/client/src/components/preview/DNDHandler.svelte index 2437386929..90e2a55ca4 100644 --- a/packages/client/src/components/preview/DNDHandler.svelte +++ b/packages/client/src/components/preview/DNDHandler.svelte @@ -105,9 +105,14 @@ const element = e.target.closest("[data-type='component']") if ( element && - element.dataset.droppable && + element.dataset.droppable === "true" && element.dataset.id !== dragInfo.target ) { + // Do nothing if this is the same target + if (element.dataset.id === dropInfo?.target) { + return + } + // Ensure the dragging flag is always set. // There's a bit of a race condition between the app reinitialisation // after selecting the DND component and setting this the first time