Added checks to ignore a drag and drop if it doesn't alter the tree structure

This commit is contained in:
Dean 2024-11-27 10:07:15 +00:00
parent c52a29df29
commit 5ccd20a00b
1 changed files with 12 additions and 2 deletions

View File

@ -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
}