From 29c780a458bfa4f41baa42991407c3ba8d060194 Mon Sep 17 00:00:00 2001 From: Dean Date: Tue, 26 Nov 2024 17:31:32 +0000 Subject: [PATCH] Removed unnecessary mouse behaviour and added in a fix for dragging an element into its own drag zone. --- .../AutomationBuilder/DraggableCanvas.svelte | 12 +----------- packages/builder/src/stores/builder/automations.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/DraggableCanvas.svelte b/packages/builder/src/components/automation/AutomationBuilder/DraggableCanvas.svelte index 9e53015f3e..b1a4f37f46 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/DraggableCanvas.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/DraggableCanvas.svelte @@ -480,12 +480,6 @@ } } - const onMoveContent = e => { - if (down || !viewPort) { - return - } - } - const isDraggable = e => { const draggable = ["draggable-view", ...draggableClasses] return draggable.some(cls => e.target.classList.contains(cls)) @@ -596,11 +590,7 @@ }} >
-
+
diff --git a/packages/builder/src/stores/builder/automations.js b/packages/builder/src/stores/builder/automations.js index 8f54f85ef5..aa35f8ca09 100644 --- a/packages/builder/src/stores/builder/automations.js +++ b/packages/builder/src/stores/builder/automations.js @@ -77,6 +77,17 @@ const automationActions = store => ({ * @param {Object} automation the automaton to be mutated */ moveBlock: async (sourcePath, destPath, automation) => { + // The last part of the source node address, containing the id. + const pathSource = sourcePath.at(-1) + + // The last part of the destination node address, containing the id. + const pathEnd = destPath.at(-1) + + // If they are the same then ignore the drag and drop + if (pathSource.id === pathEnd.id) { + return + } + // Use core delete to remove and return the deleted block // from the automation const { deleted, newAutomation } = store.actions.deleteBlock( @@ -89,9 +100,6 @@ const automationActions = store => ({ const newRefs = {} store.actions.traverse(newRefs, newAutomation) - // The last part of the destination node address, containing the id. - const pathEnd = destPath.at(-1) - let finalPath // If dropping in a branch-step dropzone you need to find // the updated parent step route then add the branch details again