Skip to content

fix: prefer ancestor drop target over nearest-by-distance in DragManager#10170

Open
mvanhorn wants to merge 2 commits into
adobe:mainfrom
mvanhorn:fix/10055-dnd-findnearestdroptarget-ancestor
Open

fix: prefer ancestor drop target over nearest-by-distance in DragManager#10170
mvanhorn wants to merge 2 commits into
adobe:mainfrom
mvanhorn:fix/10055-dnd-findnearestdroptarget-ancestor

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Drag and drop now prefers an ancestor drop target over a closer-by-distance sibling, matching how nested drop zones are expected to resolve.

Why this matters

Reported in #10055: findNearestDropTarget picked the geometrically nearest target, so a small drop zone next to a containing one could win even when the pointer was inside the container. The fix prefers an ancestor target when the pointer is within it, before falling back to nearest-by-distance.

Changes

  • Adjust DragManager's target selection to prefer an ancestor drop target containing the pointer.

Testing

Added a DnD test covering the nested-target case.

Fixes #10055

AI was used for assistance.

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, reviewers will want to pull it down and copy the codesandbox into our storybook to verify as well.
I'll hopefully have some time to try it tomorrow.

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useDragAndDrop keyboard DnD: findNearestDropTarget selects wrong collection when drag source is last item

2 participants