Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix virtualizer drag and drop with layout gaps #7886

Merged
merged 2 commits into from
Mar 7, 2025
Merged

Conversation

devongovett
Copy link
Member

When using drag and drop reorder items in a grid or list with gaps between the items, the drop target would disappear when over the gap because we were looking for items under the mouse and there were none. This was broken by the recent refactor. Now instead of using keyAtPoint, we get the items in a small rectangle that's as wide as the gap, and then find the closest item to the mouse position within that rectangle.

@rspbot
Copy link

rspbot commented Mar 7, 2025

Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

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

LGTM

@devongovett devongovett added this pull request to the merge queue Mar 7, 2025
Merged via the queue into main with commit 55113ca Mar 7, 2025
30 checks passed
@devongovett devongovett deleted the dnd-gap branch March 7, 2025 17:44
Comment on lines +239 to +240
let yDist = Math.abs(candidate.rect.y - x);
let maxYDist = Math.abs(candidate.rect.maxY - x);
Copy link
Member

Choose a reason for hiding this comment

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

maybe I'm having a brain fart and not visualizing this quite right, but shouldn't this be candidate.rect.y - y instead? Like comparing the candidate's top/bottom edge's Y position with the current point to find the closest edge -> reiterating on the next candidate to find the candidate that is closest to the drop point?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, copy pasta

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

5 participants