Skip to content

fix: bad enter/leave event order clearing drop target #14

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

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

TheFireBlast
Copy link
Contributor

Sometimes, the dragenter event fires before the dragleave event, causing the drop target container and element information to be lost. While the exact cause isn't clear, this issue occurs fairly frequently when items are positioned very close to each other (e.g., with zero margin), at least on Firefox.

This pull request simply adds a check to ensure the drop target is only set to null if it hasn’t already been replaced by another item.

@Spikeysanju Spikeysanju self-assigned this Jan 23, 2025
@Spikeysanju
Copy link
Contributor

This pull request includes changes to the droppable function in the src/lib/actions/droppable.ts file to improve the handling of drag-and-drop events. The most important changes include adding conditions to reset the targetContainer and targetElement properties in specific scenarios.

Improvements to drag-and-drop handling:

  • src/lib/actions/droppable.ts: Added a condition to reset targetContainer and targetElement when the target container and element match the current event target during the onDragLeave callback.
  • src/lib/actions/droppable.ts: Added a condition to reset targetContainer when the target container matches the current options container during the handlePointerOut event.

@Spikeysanju Spikeysanju added the bug Something isn't working label Jan 23, 2025
@Spikeysanju Spikeysanju merged commit acfab09 into thisuxhq:main Jan 23, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants