Skip to content

Commit

Permalink
Fix inaccurate position with custom drag layers (#2818)
Browse files Browse the repository at this point in the history
* fix: correct issue with `dragenter` being fired with no actual target

* chore: cut semver document

Co-authored-by: Eric Fleury <fleury@capintel.ca>
Co-authored-by: Chris Trevino <chtrevin@microsoft.com>
  • Loading branch information
3 people committed Nov 13, 2020
1 parent d5380ce commit 9934fe5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .yarn/versions/9b1fb4e7.yml
@@ -0,0 +1,7 @@
releases:
react-dnd-html5-backend: patch

declined:
- react-dnd-documentation
- react-dnd-examples-decorators
- react-dnd-examples-hooks
10 changes: 4 additions & 6 deletions packages/backend-html5/src/HTML5BackendImpl.ts
Expand Up @@ -9,7 +9,6 @@ import {
Unsubscribe,
} from 'dnd-core'
import { EnterLeaveCounter } from './EnterLeaveCounter'
import { isFirefox } from './BrowserDetector'
import {
getNodeClientOffset,
getEventClientOffset,
Expand Down Expand Up @@ -556,11 +555,10 @@ export class HTML5BackendImpl implements Backend {

this.altKeyPressed = e.altKey

if (!isFirefox()) {
// Don't emit hover in `dragenter` on Firefox due to an edge case.
// If the target changes position as the result of `dragenter`, Firefox
// will still happily dispatch `dragover` despite target being no longer
// there. The easy solution is to only fire `hover` in `dragover` on FF.
// If the target changes position as the result of `dragenter`, `dragover` might still
// get dispatched despite target being no longer there. The easy solution is to check
// whether there actually is a target before firing `hover`.
if (dragEnterTargetIds.length > 0) {
this.actions.hover(dragEnterTargetIds, {
clientOffset: getEventClientOffset(e),
})
Expand Down

0 comments on commit 9934fe5

Please sign in to comment.