Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 committed Jan 23, 2025
1 parent ced705a commit ffd171c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/dnd/src/transforms/onDropNode.ts
Original file line number Diff line number Diff line change
@@ -67,12 +67,12 @@ export const getDropPath = (
let dropPath: Path | undefined;

// if drag from file system use [] as default path
const dragPath = dragEntry?.[1] ?? [];
const dragPath = dragEntry?.[1];
const hoveredPath = dropEntry[1];

// Treat 'right' like 'bottom' (after hovered)
// Treat 'left' like 'top' (before hovered)
if (direction === 'bottom' || direction === 'right') {
if (dragPath && (direction === 'bottom' || direction === 'right')) {
// Insert after hovered node
dropPath = hoveredPath;

@@ -84,11 +84,12 @@ export const getDropPath = (
dropPath = [...hoveredPath.slice(0, -1), hoveredPath.at(-1)! - 1];

// If the dragged node is already right before hovered node, no change
if (PathApi.equals(dragPath, dropPath)) return;
if (dragPath && PathApi.equals(dragPath, dropPath)) return;
}

const _dropPath = dropPath as Path;
const before =
dragPath &&
PathApi.isBefore(dragPath, _dropPath) &&
PathApi.isSibling(dragPath, _dropPath);
const to = before ? _dropPath : PathApi.next(_dropPath);

0 comments on commit ffd171c

Please sign in to comment.