Skip to content

Commit b84c888

Browse files
committed
fix: bad enter/leave event order clearing drop target
1 parent 26c0070 commit b84c888

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/lib/actions/droppable.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ export function droppable<T>(node: HTMLElement, options: DragDropOptions<T>) {
3434

3535
options.callbacks?.onDragLeave?.(dndState as DragDropState<T>);
3636

37-
dndState.targetContainer = null;
38-
dndState.targetElement = null;
37+
if (dndState.targetContainer === options.container && dndState.targetElement === event.target) {
38+
dndState.targetContainer = null;
39+
dndState.targetElement = null;
40+
}
3941
}
4042

4143
function handleDragOver(event: DragEvent) {
@@ -87,7 +89,9 @@ export function droppable<T>(node: HTMLElement, options: DragDropOptions<T>) {
8789
function handlePointerOut(event: PointerEvent) {
8890
if (options.disabled || !dndState.isDragging) return;
8991

90-
dndState.targetContainer = null;
92+
if (dndState.targetContainer === options.container) {
93+
dndState.targetContainer = null;
94+
}
9195
node.classList.remove(...dragOverClass);
9296
options.callbacks?.onDragLeave?.(dndState as DragDropState<T>);
9397
}

0 commit comments

Comments
 (0)