DEV Community

John Builds
John Builds

Posted on

Drag-and-drop rescheduling with dnd-kit: the four edge cases that were the actual feature

We added drag-and-drop rescheduling to our social media calendar (Next.js + dnd-kit, Rails API behind it). The drag interaction took a day. The edge cases took the week, and they turned out to be the feature:

Slot snapping. Users define posting schedules (weekdays 9am/4pm). A drop shouldn't produce 15:47 because that's where the cursor was — we resolve every drop to the nearest valid slot in the user's schedule.

Collision validation. Dropping onto an occupied slot used to stack posts silently. Drops are now validated server-side against existing scheduled posts before committing, with a warning UI on conflict.

Undo. Drag is the one mutation where prior state vanishes from view — the post is just somewhere else now. We restore the exact previous timestamp on one keystroke instead of keeping a generic history stack.

Pin-aware reflow. Posts anchored to fixed moments (launches) must not move when the queue redistributes; everything else flows around them.

If you're building anything calendar-shaped: spec the misdrag, the conflict, and the take-back before the drag itself. That's where users decide whether they trust you with their schedule.

Live in XreplyAI: https://xreplyai.com?utm_source=devto&utm_medium=social&utm_campaign=feature-2026-06-12

Top comments (0)