From 99c7859fb2796aa3b39956e484d34a3fb249749f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 1 Aug 2024 09:00:18 +0100 Subject: [PATCH] Fix DND ghost cursor issue on mac --- .../src/components/preview/GridDNDHandler.svelte | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/client/src/components/preview/GridDNDHandler.svelte b/packages/client/src/components/preview/GridDNDHandler.svelte index 62cabc14cd..374defe138 100644 --- a/packages/client/src/components/preview/GridDNDHandler.svelte +++ b/packages/client/src/components/preview/GridDNDHandler.svelte @@ -10,6 +10,15 @@ getGridVarValue, } from "utils/grid" + // Smallest possible 1x1 transparent GIF + const ghost = new Image(1, 1) + ghost.src = + "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" + + let dragInfo + let gridStyles = memo() + let id + // Grid CSS variables $: vars = { colStart: $getGridVar("col-start"), @@ -18,10 +27,6 @@ rowEnd: $getGridVar("row-end"), } - let dragInfo - let gridStyles = memo() - let id - // Some memoisation of primitive types for performance $: id = dragInfo?.id || id @@ -117,7 +122,7 @@ } // Hide drag ghost image - e.dataTransfer.setDragImage(new Image(), 0, 0) + e.dataTransfer.setDragImage(ghost, 0, 0) // Extract state let mode, id, side