From c888b703ddfbff333b1b2b417f01bf92918c8e2a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 24 Oct 2022 13:32:48 +0100 Subject: [PATCH] Improve comments and namimg conventions --- packages/client/src/components/preview/DNDHandler.svelte | 6 ++++-- .../client/src/components/preview/GridDNDHandler.svelte | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/preview/DNDHandler.svelte b/packages/client/src/components/preview/DNDHandler.svelte index 42a2fafbdd..1855166e0c 100644 --- a/packages/client/src/components/preview/DNDHandler.svelte +++ b/packages/client/src/components/preview/DNDHandler.svelte @@ -25,7 +25,9 @@ // Local flag for whether we are awaiting an async drop event let dropping = false - const insideGrid = e => { + // Util to check if a DND event originates from a grid (or inside a grid). + // This is important as we do not handle grid DND in this handler. + const isGridEvent = e => { return e.target ?.closest?.(".component") ?.parentNode?.closest?.(".component") @@ -69,7 +71,7 @@ // Callback when initially starting a drag on a draggable component const onDragStart = e => { - if (insideGrid(e)) { + if (isGridEvent(e)) { return } const component = e.target.closest(".component") diff --git a/packages/client/src/components/preview/GridDNDHandler.svelte b/packages/client/src/components/preview/GridDNDHandler.svelte index 61bd8db08f..46e2e575b0 100644 --- a/packages/client/src/components/preview/GridDNDHandler.svelte +++ b/packages/client/src/components/preview/GridDNDHandler.svelte @@ -17,7 +17,9 @@ ...(gridStyles ? { "z-index": 999 } : null), }) - const isChildOfGrid = e => { + // Util to check if a DND event originates from a grid (or inside a grid). + // This is important as we do not handle grid DND in this handler. + const isGridEvent = e => { return ( e.target .closest?.(".component") @@ -113,7 +115,7 @@ // Callback when initially starting a drag on a draggable component const onDragStart = e => { - if (!isChildOfGrid(e)) { + if (!isGridEvent(e)) { return }