RESOLVED FIXED 244149
REGRESSION (iOS 16): New context menu (UIEditMenuInteraction) can't be disabled
https://bugs.webkit.org/show_bug.cgi?id=244149
Summary REGRESSION (iOS 16): New context menu (UIEditMenuInteraction) can't be disabled
Kurt Revis
Reported 2022-08-19 17:15:30 PDT
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'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't work. The handler fires but `preventDefault()` has no effect. - Looked for relevant delegate methods, but there aren't any. The closest thing is these WKUIDelegate methods to be called when the menu appears and disappears, but that's all: https://bugs.webkit.org/show_bug.cgi?id=243102 Those would only let us add animations alongside the menu, anyway. They wouldn't let us disable the menu or customize its items. - Looked for any UIKit API to globally disable the new edit menu, but there's nothing. Could we please have a way to disable this thing? Ideally via calling `preventDefault()` on the `contextmenu` event?
Attachments
Kurt Revis
Comment 1 2022-08-19 17:17:23 PDT
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.
Radar WebKit Bug Importer
Comment 2 2022-08-20 19:00:50 PDT
Devin Rousso
Comment 3 2022-08-23 10:51:17 PDT
@Kurt Revis, I'm told that maybe overriding `-buildMenuWithBuilder:` would allow you to control this. Could you give that a try?
Kurt Revis
Comment 4 2022-08-23 11:54:56 PDT
That solution wouldn'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't call super, the menu still appears, with a few items (Copy, Select all, Translate, Share). We don'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'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's good, at least.)
Devin Rousso
Comment 5 2022-09-29 17:32:17 PDT
EWS
Comment 6 2022-10-05 14:23:11 PDT
Committed 255193@main (9ce57ec0f4b3): <https://commits.webkit.org/255193@main> Reviewed commits have been landed. Closing PR #4845 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.