PointerSensor ends a drag without applying the last pointer move, so the drop lags the release by one frame

Open Beginner friendly
#2,201 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
frontend

Research direction

Start in @dnd-kit/[email protected]/index.js at PointerSensor.handlePointerMove, handlePointerUp, and cleanup, and read the scheduler in utilities.js around line 779 to see how handleMove is queued. Reproduce with a Playwright drag that calls mouse.down(), mouse.move(x, y), then mouse.up() without waiting, logging event.operation.target?.id and event.operation.transform in dragend. Done means handlePointerUp applies this.latest or the pointerup coordinates before actions.stop, so dragend reflects the release position.

Written by the indexing model from the issue text.

Description

@dnd-kit/dom 0.5.3

A drop resolves against the pointer position of the last animation frame, not the position where the pointer was released. If the pointer moves and is released within the same frame, the final move is dropped: dragend reports the previous transform and the previous target.

Where it comes from (line numbers are @dnd-kit/[email protected]/index.js)

  • PointerSensor.handlePointerMove records the move in this.latest and schedules handleMove for the next animation frame (scheduler.schedule(this.handleMove), line 2206; the scheduler uses requestAnimationFrame, utilities.js line 779).
  • handlePointerUp (lines 2210-2232) calls this.manager.actions.stop({ event, canceled }) without applying the pending this.latest move first.
  • It then calls this.cleanup(), which resets this.latest (line 2306), so when the scheduled handleMove runs it returns early (lines 2085-2088) and the move is never applied.

So position.current, the transform derived from it, and the collision that picks the drop target all stay one frame behind the release.

How to see it

  1. Register one draggable and two droppables side by side, and log event.operation.target?.id and event.operation.transform in a dragend listener.
  2. With a scripted pointer (for example Playwright's mouse.down(), mouse.move(x, y), mouse.up() with no wait between the last move and the release), drag from the draggable onto the second droppable.
  3. dragend reports the target and transform from the move before the last one; the final pointermove is not reflected. A hand drag that keeps moving until the release shows the same lag, by at most one frame of pointer travel.

Expected

dragend reflects the release position: handlePointerUp applies the pending move (or the pointerup coordinates) before calling actions.stop.

Dominant language
TypeScript
Stars
17.8k
Forks
934
Avg merge
12h 5m
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from clauderic/dnd-kit

All issues in clauderic/dnd-kit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.