Skip to content

Commit 9934fe5

Browse files
efleury1Eric Fleurydarthtrevino
authored
Fix inaccurate position with custom drag layers (#2818)
* 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>
1 parent d5380ce commit 9934fe5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.yarn/versions/9b1fb4e7.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
releases:
2+
react-dnd-html5-backend: patch
3+
4+
declined:
5+
- react-dnd-documentation
6+
- react-dnd-examples-decorators
7+
- react-dnd-examples-hooks

packages/backend-html5/src/HTML5BackendImpl.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
Unsubscribe,
1010
} from 'dnd-core'
1111
import { EnterLeaveCounter } from './EnterLeaveCounter'
12-
import { isFirefox } from './BrowserDetector'
1312
import {
1413
getNodeClientOffset,
1514
getEventClientOffset,
@@ -556,11 +555,10 @@ export class HTML5BackendImpl implements Backend {
556555

557556
this.altKeyPressed = e.altKey
558557

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

0 commit comments

Comments
 (0)