From 700646468683e4820269534c6352cca93bb5a987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claud=C3=A9ric=20Demers?= Date: Wed, 21 Jul 2021 10:58:19 -0400 Subject: [PATCH] fix: do not wrap consumer-defined handlers in batchedUpdates (#371) --- .changeset/fix-batchedupdates-handlers.md | 5 +++++ .../core/src/components/DndContext/DndContext.tsx | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .changeset/fix-batchedupdates-handlers.md 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); + } }; } },