Skip to content

fix: keep drop preview tracking when scrolling mid-drag - #18

Merged
Horuse merged 1 commit into
mainfrom
fix/scroll-during-drag
Jun 29, 2026
Merged

Horuse merged 1 commit into
mainfrom
fix/scroll-during-drag

Conversation

@Horuse

@Horuse Horuse commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Fixes #17.

Scrolling mid-drag left the drop preview stale and made dropping impossible.

Changes

  • DndController.recomputeDropPreview() re-resolves the preview against the last known pointer position; the droppable scroll handler calls it after refreshing zones, so the preview keeps tracking under a stationary cursor.
  • Scroll listeners now also attach to the droppable element itself and to nested [data-dnd-scroll] viewports, so virtualized lists (virtua) whose scroll viewport is a descendant are covered. Scroll events do not bubble, hence the direct listener.

Tests

  • Added tests/entities/droppable-scroll.test.ts covering own-element scroll, nested data-dnd-scroll viewport, and listener cleanup after drag end.

Re-resolve the drop preview against the last pointer position on scroll, and
listen on nested data-dnd-scroll viewports so virtualized lists are covered.

Closes #17
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
svelte-dnd Ready Ready Preview, Comment Jun 29, 2026 6:46pm

@Horuse
Horuse merged commit 0894d9d into main Jun 29, 2026
4 checks passed
@Horuse
Horuse deleted the fix/scroll-during-drag branch June 29, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag breaks when scrolling the wheel mid-drag

1 participant