<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>242627</bug_id>
          
          <creation_ts>2022-07-11 19:12:19 -0700</creation_ts>
          <short_desc>event.relatedTarget is always null for dragenter and dragleave events</short_desc>
          <delta_ts>2022-07-12 14:21:55 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>UI Events</component>
          <version>Safari 15</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 12</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>66547</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=66547</see_also>
          <bug_file_loc>https://codesandbox.io/s/event-relatedtarget-for-dragenter-and-dragleave-safari-bug-gpph01</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>alexreardon</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1882319</commentid>
    <comment_count>0</comment_count>
    <who name="">alexreardon</who>
    <bug_when>2022-07-11 19:12:19 -0700</bug_when>
    <thetext>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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1882320</commentid>
    <comment_count>1</comment_count>
    <who name="">alexreardon</who>
    <bug_when>2022-07-11 19:13:30 -0700</bug_when>
    <thetext>This bug is related to: https://bugs.webkit.org/show_bug.cgi?id=66547

But that bug was only for the `dragleave` event</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1882569</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2022-07-12 14:21:55 -0700</bug_when>
    <thetext>As mentioned, generalising the other bug to cover both events.

*** This bug has been marked as a duplicate of bug 66547 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>