<?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>244149</bug_id>
          
          <creation_ts>2022-08-19 17:15:30 -0700</creation_ts>
          <short_desc>REGRESSION (iOS 16): New context menu (UIEditMenuInteraction) can&apos;t be disabled</short_desc>
          <delta_ts>2023-08-28 10:50:05 -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>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=260722</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kurt Revis">krevis</reporter>
          <assigned_to name="Devin Rousso">hi</assigned_to>
          <cc>hi</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1892564</commentid>
    <comment_count>0</comment_count>
    <who name="Kurt Revis">krevis</who>
    <bug_when>2022-08-19 17:15:30 -0700</bug_when>
    <thetext>In iPadOS 16 beta 6, WKWebView shows the system edit menu (via UIEditMenuInteraction) when you control-click or right-click or two-finger-click anywhere in the web view.

We have our own handling of these events, so we don&apos;t want that menu, but there appears to be no way to disable it, or customize it.

- Tried catching the `contextmenu` event and calling `preventDefault`, as shown in the example in the MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event
  Example: https://codepen.io/krevis-figma/pen/yLKejBa
  This doesn&apos;t work. The handler fires but `preventDefault()` has no effect.

- Looked for relevant delegate methods, but there aren&apos;t any.
  The closest thing is these WKUIDelegate methods to be called when the menu appears and disappears, but that&apos;s all:
  https://bugs.webkit.org/show_bug.cgi?id=243102
  Those would only let us add animations alongside the menu, anyway. They wouldn&apos;t let us disable the menu or customize its items.

- Looked for any UIKit API to globally disable the new edit menu, but there&apos;s nothing.

Could we please have a way to disable this thing?  Ideally via calling `preventDefault()` on the `contextmenu` event?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892566</commentid>
    <comment_count>1</comment_count>
    <who name="Kurt Revis">krevis</who>
    <bug_when>2022-08-19 17:17:23 -0700</bug_when>
    <thetext>Even worse, showing and dismissing this menu causes the trackpad/mouse to stop sending `pointerdown` events, as in https://bugs.webkit.org/show_bug.cgi?id=236390.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892757</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-08-20 19:00:50 -0700</bug_when>
    <thetext>&lt;rdar://problem/98935540&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1893271</commentid>
    <comment_count>3</comment_count>
    <who name="Devin Rousso">hi</who>
    <bug_when>2022-08-23 10:51:17 -0700</bug_when>
    <thetext>@Kurt Revis, I&apos;m told that maybe overriding `-buildMenuWithBuilder:` would allow you to control this.  Could you give that a try?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1893287</commentid>
    <comment_count>4</comment_count>
    <who name="Kurt Revis">krevis</who>
    <bug_when>2022-08-23 11:54:56 -0700</bug_when>
    <thetext>That solution wouldn&apos;t help pure web content. In Safari on MacOS, preventDefault() stops the system context menu from appearing. That should also work on iPadOS.

I can override -buildMenuWithBuilder: on a subclass of WKWebView, and it is called.  But if I do nothing and don&apos;t call super, the menu still appears, with a few items (Copy, Select all, Translate, Share). We don&apos;t want the menu to appear at all.

UIMenuBuilder does not provide a way to determine what items are actually in the menu so far, but I can just blindly guess, and remove the ones I think might be there. That&apos;s a pretty fragile workaround, though.

(If I do succeed in removing all the items, then nothing appears, and the pointer-event bug is not triggered. So that&apos;s good, at least.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1902233</commentid>
    <comment_count>5</comment_count>
    <who name="Devin Rousso">hi</who>
    <bug_when>2022-09-29 17:32:17 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/4845</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1903529</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-10-05 14:23:11 -0700</bug_when>
    <thetext>Committed 255193@main (9ce57ec0f4b3): &lt;https://commits.webkit.org/255193@main&gt;

Reviewed commits have been landed. Closing PR #4845 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>