diff --git a/.changeset/fix-batchedupdates-handlers.md b/.changeset/fix-batchedupdates-handlers.md new file mode 100644 index 00000000..7166bd07 --- /dev/null +++ b/.changeset/fix-batchedupdates-handlers.md @@ -0,0 +1,5 @@ +--- +"@dnd-kit/core": patch +--- + +fix: do not wrap consumer-defined handlers in batchedUpdates diff --git a/packages/core/src/components/DndContext/DndContext.tsx b/packages/core/src/components/DndContext/DndContext.tsx index a6dbb32c..206ffb09 100644 --- a/packages/core/src/components/DndContext/DndContext.tsx +++ b/packages/core/src/components/DndContext/DndContext.tsx @@ -342,8 +342,9 @@ export const DndContext = memo(function DndContext({ active: id, }); setMonitorState({type: Action.DragStart, event}); - onDragStart?.(event); }); + + onDragStart?.(event); }, onMove(coordinates) { dispatch({ @@ -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); + } }; } },