Skip to content

Commit

Permalink
Remove check for current item
Browse files Browse the repository at this point in the history
  • Loading branch information
mbraak committed Dec 4, 2024
1 parent 6a1ab48 commit d04015c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/dragAndDropHandler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,14 @@ export class DragAndDropHandler {
this.currentItem = null;
}

private canMoveToArea(area: HitArea): boolean {
private canMoveToArea(area: HitArea, currentItem: NodeElement): boolean {
if (!this.onCanMoveTo) {
return true;
}

if (!this.currentItem) {
return false;
}

const positionName = getPositionName(area.position);

return this.onCanMoveTo(this.currentItem.node, area.node, positionName);
return this.onCanMoveTo(currentItem.node, area.node, positionName);
}

private clear(): void {
Expand Down Expand Up @@ -203,7 +199,7 @@ export class DragAndDropHandler {
this.currentItem &&
this.hoveredArea &&
this.hoveredArea.position !== Position.None &&
this.canMoveToArea(this.hoveredArea)
this.canMoveToArea(this.hoveredArea, this.currentItem)
) {
const movedNode = this.currentItem.node;
const targetNode = this.hoveredArea.node;
Expand Down Expand Up @@ -351,7 +347,7 @@ export class DragAndDropHandler {
positionInfo.pageY,
);

if (area && this.canMoveToArea(area)) {
if (area && this.canMoveToArea(area, this.currentItem)) {
if (!area.node.isFolder()) {
this.stopOpenFolderTimer();
}
Expand Down

0 comments on commit d04015c

Please sign in to comment.