From d04ae2f72861e505d58c59693700c232d7253ac4 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Tue, 8 Dec 2020 20:25:47 +0200 Subject: [PATCH] fix: don't run hover animation frame after the drag has ended --- src/utils/dnd-manager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/dnd-manager.js b/src/utils/dnd-manager.js index 6adb8dca..bc8fdd14 100644 --- a/src/utils/dnd-manager.js +++ b/src/utils/dnd-manager.js @@ -235,9 +235,14 @@ export default class DndManager { // throttle `dragHover` work to available animation frames cancelAnimationFrame(this.rafId); this.rafId = requestAnimationFrame(() => { + const item = monitor.getItem() + // skip if drag already ended before the animation frame + if (!item || !monitor.isOver()) { + return; + } this.dragHover({ node: draggedNode, - path: monitor.getItem().path, + path: item.path, minimumTreeIndex: dropTargetProps.listIndex, depth: targetDepth, });