RESOLVED DUPLICATE of bug 66547 Bug 242627
event.relatedTarget is always null for dragenter and dragleave events
https://bugs.webkit.org/show_bug.cgi?id=242627
Summary event.relatedTarget is always null for dragenter and dragleave events
alexreardon
Reported 2022-07-11 19:12:19 PDT
According to my reading of the [drag and drop spec](https://html.spec.whatwg.org/multipage/dnd.html#dnd), as well as the behaviour of Chrome and Firefox, `dragenter` and `dragleave` events are supposed to set the related target event property (`event.relatedTarget`). - `dragenter`: `event.relatedTarget` is the previous _current target element_ (where the drag is coming from) - `dragleave`: `event.relatedTarget` is the new _current target element_ (where the drag has gone too) When dragging into a window: `event.relatedTarget` should be `null` on `dragenter` When dragging out of a window: `event.relatedTarget` should be `null` on `dragleave` In Safari, for `dragenter` and `dragleave` events, the `event.relatedTarget` property is _always_ `null`. This is unhelpful. Doing this makes it painful to detect when a drag is entering / exiting the window. Reproduction case: - sandbox: https://codesandbox.io/s/event-relatedtarget-for-dragenter-and-dragleave-safari-bug-gpph01 - independent example: https://gpph01.csb.app/ As a work around you need to count `dragenter` and `dragleave` events to determine whether a drag is entering / leaving a window
Attachments
alexreardon
Comment 1 2022-07-11 19:13:30 PDT
This bug is related to: https://bugs.webkit.org/show_bug.cgi?id=66547 But that bug was only for the `dragleave` event
Sam Sneddon [:gsnedders]
Comment 2 2022-07-12 14:21:55 PDT
As mentioned, generalising the other bug to cover both events. *** This bug has been marked as a duplicate of bug 66547 ***
Note You need to log in before you can comment on or make changes to this bug.