Skip to content

Conversation

istateside
Copy link
Contributor

This PR fixes an issue in Firefox where dragging links would still trigger native drag and drop behavior, even if the drag was caught as a custom defined drag type.

The codebase checks for native drag events firing, but mostly treats them separately from custom drag events. In Firefox, dragging an <a> link will still trigger native drop behavior (following the URL), because we only preventDefault() if a custom drag type was not recognized in the e.dataTransfer object.

This PR adds another check to the handleTopDropCapture function, which will prevent default if the drop event has a native type and the drag monitor is reporting the current drag as a custom type.

@istateside istateside requested a review from darthtrevino as a code owner July 30, 2021 22:54
@istateside istateside force-pushed the fix-unexpected-native-drops branch from a5e0023 to 1a31238 Compare August 6, 2021 17:06
@codecov
Copy link

codecov bot commented Aug 6, 2021

Codecov Report

Merging #3272 (1a31238) into main (1ed2a13) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3272      +/-   ##
==========================================
- Coverage   56.56%   56.56%   -0.01%     
==========================================
  Files         263      263              
  Lines        3868     3870       +2     
  Branches      760      761       +1     
==========================================
+ Hits         2188     2189       +1     
- Misses       1679     1680       +1     
  Partials        1        1              
Impacted Files Coverage Δ
packages/backend-html5/src/HTML5BackendImpl.ts 71.98% <50.00%> (-0.15%) ⬇️

@istateside
Copy link
Contributor Author

I'm getting a failure on this PR because of a drop in code coverage - i'm not quite sure where to put a test for this behavior. We'd have to a drag interaction with a custom drag type, on an element that will trigger a native drag type - and I think it would only be effective in Firefox?

Happy to write a test if someone can point me to where to do so

Copy link
Member

@darthtrevino darthtrevino left a comment

Choose a reason for hiding this comment

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

LGTM, I'll test this out locally first

@darthtrevino darthtrevino merged commit 0961b40 into react-dnd:main Aug 12, 2021
darthtrevino pushed a commit that referenced this pull request Feb 3, 2022
* Fixes #3179 - handle custom drag sources triggering native drops

* Include version update
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.

2 participants