<?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>218923</bug_id>
          
          <creation_ts>2020-11-13 15:11:45 -0800</creation_ts>
          <short_desc>iOS: click event doesn&apos;t get dispatched when there is a click event listener on ShadowRoot</short_desc>
          <delta_ts>2022-07-03 16:37:23 -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 14</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 13</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=198559</see_also>
          <bug_file_loc>https://jsfiddle.net/to2mgsy0/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, HTML5, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Blocker</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>148695</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Lionel Seguin">lionel.seguin</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>cdumez</cc>
    
    <cc>hi</cc>
    
    <cc>rniwa</cc>
    
    <cc>smoley</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1707404</commentid>
    <comment_count>0</comment_count>
      <attachid>414097</attachid>
    <who name="Lionel Seguin">lionel.seguin</who>
    <bug_when>2020-11-13 15:11:45 -0800</bug_when>
    <thetext>Created attachment 414097
File to launch on iOS nothing will happen by clicking on &quot;CLICK ME&quot;

This issue is happening only on iOS.

First you have to create the following DOM (the file attached is doing it):

&lt;my-custom-element onclick=&quot;alert(&apos;CUSTOM BUTTON CLICKED&apos;)&quot;&gt;
  #shadowRoot
     &lt;span&gt;
       &quot;button is:&quot;
       &lt;slot&gt;&lt;/slot&gt;
     &lt;/span&gt;
  &quot;Some Text&quot;
&lt;/my-custom-element&gt;

when the dom is created you can add a listener to the shadowRoot like this:

```javascript
document.querySelector(&apos;my-custom-element&apos;)
  .shadowRoot
  .addEventListener(&apos;click&apos;, () =&gt; { alert(&apos;CLICK EVENT FIRED&apos;); });
```

now you can press the &quot;span&quot; and you will see no event is fired. There is no alert at all displayed.

The issue is related to the listener we have on the shadowRoot. If we don&apos;t have it the first listener is working well.


Another strange behaviour is if you had an other listener on the &quot;span&quot; like this:

```javascript
document.querySelector(&apos;my-custom-element&apos;)
  .shadowRoot
  .querySelector(&apos;span&apos;)
  .addEventListener(&apos;click&apos;, () =&gt; { alert(&apos;SPAN CLICKED&apos;); });
```

Now if you press the button the probleme is fixed the 3 handlers are well called as expected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1707496</commentid>
    <comment_count>1</comment_count>
    <who name="Lionel Seguin">lionel.seguin</who>
    <bug_when>2020-11-14 05:33:25 -0800</bug_when>
    <thetext>The biggest impact of this issue is when a third party script is capturing events coming from a shadow root, it impacts the initial behaviour of the custom component.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1707497</commentid>
    <comment_count>2</comment_count>
    <who name="Lionel Seguin">lionel.seguin</who>
    <bug_when>2020-11-14 05:49:51 -0800</bug_when>
    <thetext>Another information.

Attaching any of those events to the shadowRoot will change the initial component behaviour:

- mouseover
- click
- mousedown
- mouseup
- mousemove</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1708071</commentid>
    <comment_count>3</comment_count>
    <who name="Smoley">smoley</who>
    <bug_when>2020-11-16 18:33:07 -0800</bug_when>
    <thetext>Thanks for filing. I can reproduce this with the provided test case on iOS 13.6.1 and the current iOS 14.3 beta.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1708072</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-11-16 18:33:16 -0800</bug_when>
    <thetext>&lt;rdar://problem/71468598&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1880408</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-03 02:11:52 -0700</bug_when>
    <thetext>This was a bizarre bug! It all comes down to WebPage::commitPotentialTap failing to dispatch click event because ShadowRoot doesn&apos;t have a renderer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1880409</commentid>
    <comment_count>6</comment_count>
      <attachid>460637</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-03 02:13:32 -0700</bug_when>
    <thetext>Created attachment 460637
WIP</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1880431</commentid>
    <comment_count>7</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-03 13:36:25 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/2043</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1880437</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-07-03 16:37:21 -0700</bug_when>
    <thetext>Committed 252107@main (b01e40564c21): &lt;https://commits.webkit.org/252107@main&gt;

Reviewed commits have been landed. Closing PR #2043 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>414097</attachid>
            <date>2020-11-13 15:11:45 -0800</date>
            <delta_ts>2020-11-13 15:11:45 -0800</delta_ts>
            <desc>File to launch on iOS nothing will happen by clicking on &quot;CLICK ME&quot;</desc>
            <filename>safari-ios-bug.html</filename>
            <type>text/html</type>
            <size>902</size>
            <attacher name="Lionel Seguin">lionel.seguin</attacher>
            
              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
aWNrJywgKCkgPT4gewogICAgICAgIGFsZXJ0KCdZT1UgU0hPVUxEIFNFRSBUSElTIEFTIFdFTEwg
OiknKTsKICAgICAgfSk7CiAgICA8L3NjcmlwdD4KICA8L2JvZHk+CjwvaHRtbD4=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>460637</attachid>
            <date>2022-07-03 02:13:32 -0700</date>
            <delta_ts>2022-07-03 02:13:32 -0700</delta_ts>
            <desc>WIP</desc>
            <filename>wip218923.patch</filename>
            <type>text/plain</type>
            <size>1099</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQvV2ViUHJvY2Vzcy9XZWJQYWdlL2lvcy9XZWJQYWdl
SU9TLm1tIGIvU291cmNlL1dlYktpdC9XZWJQcm9jZXNzL1dlYlBhZ2UvaW9zL1dlYlBhZ2VJT1Mu
bW0KaW5kZXggZmIxYzVmOWYwOWFlLi42ODdlNGM0OWRiNDIgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9X
ZWJLaXQvV2ViUHJvY2Vzcy9XZWJQYWdlL2lvcy9XZWJQYWdlSU9TLm1tCisrKyBiL1NvdXJjZS9X
ZWJLaXQvV2ViUHJvY2Vzcy9XZWJQYWdlL2lvcy9XZWJQYWdlSU9TLm1tCkBAIC0xMTQwLDcgKzEx
NDAsOSBAQCB2b2lkIFdlYlBhZ2U6OmNvbW1pdFBvdGVudGlhbFRhcChPcHRpb25TZXQ8V2ViRXZl
bnQ6Ok1vZGlmaWVyPiBtb2RpZmllcnMsIFRyYW5zYQogICAgICAgICBib29sIHRhcmdldFJlbmRl
cnMgPSBtX3BvdGVudGlhbFRhcE5vZGUtPnJlbmRlcmVyKCk7CiAgICAgICAgIGlmICghdGFyZ2V0
UmVuZGVycyAmJiBpczxFbGVtZW50PihtX3BvdGVudGlhbFRhcE5vZGUpKQogICAgICAgICAgICAg
dGFy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