Description
When handling the dragend event from DragDropProvider, both event.operation.source.id and event.operation.target.id return the same value (the target's ID), even when the dragged item was moved to a different position.
This makes it impossible to detect whether an item was actually moved or dropped in place, as comparing source.id !== target.id always evaluates to false.
Reproduction
<script lang="ts">
import { DragDropProvider, type DragDropEvents } from "@dnd-kit-svelte/svelte";
const handleDragEnd: DragDropEvents<MyData>["dragend"] = (event) => {
const { source, target } = event.operation;
console.log("source.id:", source?.id); // e.g., "item-3"
console.log("target.id:", target?.id); // e.g., "item-3" (same value!)
// This condition is never true, even when items are visually moved
if (source?.id !== target?.id) {
// Reorder logic never executes...
}
};
</script>
<DragDropProvider onDragEnd={handleDragEnd}>
<!-- sortable items -->
</DragDropProvider>
Description
When handling the
dragendevent fromDragDropProvider, bothevent.operation.source.idandevent.operation.target.idreturn the same value (the target's ID), even when the dragged item was moved to a different position.This makes it impossible to detect whether an item was actually moved or dropped in place, as comparing
source.id !== target.idalways evaluates tofalse.Reproduction