From 5ccd20a00b02f09f14b586801219e9fa591f4202 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 27 Nov 2024 10:07:15 +0000 Subject: [PATCH] Added checks to ignore a drag and drop if it doesn't alter the tree structure --- packages/builder/src/stores/builder/automations.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/stores/builder/automations.js b/packages/builder/src/stores/builder/automations.js index 08d5cbe816..d9e9f39f0f 100644 --- a/packages/builder/src/stores/builder/automations.js +++ b/packages/builder/src/stores/builder/automations.js @@ -84,8 +84,18 @@ const automationActions = store => ({ // 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) { + // Check if dragging a step into its own drag zone + const isOwnDragzone = pathSource.id === pathEnd.id + + // Check if dragging the first branch step into the branch node drag zone + const isFirstBranchStep = + pathEnd.branchStepId && + pathEnd.branchIdx === pathSource.branchIdx && + pathSource.stepIdx === 0 + + // If dragging into an area that will not affect the tree structure + // Ignore the drag and drop. + if (isOwnDragzone || isFirstBranchStep) { return }