Skip to content

Commit

Permalink
fix: do not wrap consumer-defined handlers in batchedUpdates (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
clauderic authored Jul 21, 2021
1 parent eeb990a commit 7006464
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix-batchedupdates-handlers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@dnd-kit/core": patch
---

fix: do not wrap consumer-defined handlers in batchedUpdates
15 changes: 9 additions & 6 deletions packages/core/src/components/DndContext/DndContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ export const DndContext = memo(function DndContext({
active: id,
});
setMonitorState({type: Action.DragStart, event});
onDragStart?.(event);
});

onDragStart?.(event);
},
onMove(coordinates) {
dispatch({
Expand Down Expand Up @@ -392,14 +393,16 @@ export const DndContext = memo(function DndContext({
setActivatorEvent(null);

if (event) {
const {onDragCancel, onDragEnd} = latestProps.current;
const handler =
type === Action.DragEnd ? onDragEnd : onDragCancel;

setMonitorState({type, event});
handler?.(event);
}
});

if (event) {
const {onDragCancel, onDragEnd} = latestProps.current;
const handler = type === Action.DragEnd ? onDragEnd : onDragCancel;

handler?.(event);
}
};
}
},
Expand Down

0 comments on commit 7006464

Please sign in to comment.