Bug 213953 - AX: contextmenu event fired on Mac (w/VoiceOver) but not iOS (w/VoiceOver)
Summary: AX: contextmenu event fired on Mac (w/VoiceOver) but not iOS (w/VoiceOver)
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Safari 13
Hardware: All All
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2020-07-03 23:15 PDT by cookiengineer+webkit
Modified: 2023-09-26 02:09 PDT (History)
8 users (show)

See Also:

Reduced test case for contextmenu event (597 bytes, text/html)
2020-07-03 23:15 PDT, cookiengineer+webkit
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description cookiengineer+webkit 2020-07-03 23:15:54 PDT
Created attachment 403513 [details]
Reduced test case for contextmenu event

Safari mobile (on iOS) doesn't fire the "contextmenu" event on elements, and therefore doesn't allow easy integration of html custom context menus.

When using addEventListener('contextmenu') on an element, by default the magnifier is always fired (even if the element doesn't have any text content). When using "-webkit-user-select: none" and "user-select: none", the magnifier is disabled - though the contextmenu event isn't fired anyhow.

The attachment is a reduced test case, where other browsers on other operating systems will behave like expected, and a long-press on mobile (or right click on desktop) of an element leads to the rectangle turning green. Only WebKit/Safari on iOS seems to not allow contextmenu events.
Comment 1 Radar WebKit Bug Importer 2020-07-04 14:08:15 PDT
Comment 2 James Craig 2021-03-18 09:36:23 PDT
AX: contextmenu event fired on Mac (w/VoiceOver) but not iOS (w/VoiceOver)

On Mac with VO, pressing VO+Shift+M (show contextual menu) triggers the `contextmenu` JavaScript event, equivalent to a mouse-triggered right-click or Ctrl+click. I assume this is because of a Mac implementation detail, and that it's been this way since `contextmenu` was implemented in WebKit... This is expected behavior on Mac.

On iOS, there are accessibility-triggered ways to show context menus in native UI: Home Screen icons for example. VoiceOver's default gesture for this is single-finger triple-tap. It used to be long-press, as mentioned by "cookiengineer" (no relation). The iOS VO key press is the same as Mac: VO+Shift+M. Yet neither of these trigger in Safari or other WebKit views.

I don't think this is purely an accessibility issue. As far as I am aware, there is no mainstream UI way to trigger a `contextmenu` event in iOS WebKit. As such, we should not add an accessibility-only way to trigger this event, as it could reveal the use of assistive technology.

Perhaps this bug should be blocked on a new WebKit issue to support `contextmenu` with a mainstream gesture or keypress if appropriate. (Disclaimer: I have not fully considered the implications, so there may be unexpected downsides.)
Comment 3 James Craig 2021-03-18 12:45:18 PDT
Update, contextmenu is triggered with right-click/ctrl-click when a BT mouse is connected to iPad.
Comment 4 Alex 2023-09-26 02:09:42 PDT
"contextmenu" is not just about menus, but it is a convenient way to detect longpress on Android devices. Without it we have to use a combination of timeout hacks on pointerstart, pointerend, pointercancel, pointermove and whatnot. Would be great if iOS supported it.