This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
[Bug]: Preventing context menu / "contextmenu"
event through preventDefault
for an img
element does not work.
#21929
Labels
Steps to reproduce
img
element and add a"contextmenu"
listener to it that callspreventDefault
(the listener can also have the argumentpassive
set tofalse
when adding the listener usingaddEventListener
).img
.Expected behaviour
A context menu should not open.
Actual behaviour
A context menu unexpectedly opens.
Device name
Galaxy A20s
Android version
Android 11
Firefox release type
Firefox
Firefox version
93.1.0 (Build #2015836707)
Device logs
No response
Additional information
Somewhat minimal reproducible example
https://jsfiddle.net/nc1zuref/ :
img
s correctly do not show context menus, while the thirdimg
correctly does show the context menu.img
s show the context menu.(note that the third
img
is added purely for the sake of having something to compare with).Related bugs
This bug may be related to #14067 . I have tried searching for "context menu" and "contextmenu" with the label "🐞+bug", but did not find any open issue that matched.
How this bug can cause problems
One example where this bug can give problems is if you have a touch event listener on an
img
, where the user for some actions is meant to continue to touch down on theimg
for longer periods (for instance for moving some graphical element around while still being able to see the graphical element), detecting the specific touch position on theimg
, and where there is a real-time aspect to it. The context menu appearing suddenly is therefore troublesome. It works on Chrome on Android. I don't know what an easy work-around would be, apart from finding and using some element other thanimg
wherepreventDefault
does work for the"contextmenu"
event for Firefox on Android (while I have not looked into it, I would assume that it would work for some element other thanimg
).┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: