[w3c/uievents] Introduce contextmenuclose or similar event. (#309)

There is a [contextmenu event](https://html.spec.whatwg.org/multipage/indices.html#event-contextmenu) fired when the user right clicks or long presses (with touch) to show a context menu (Note #279 proposes adding this event to UI Events). There is however no notification about the closing of that menu. Developers typically call preventDefault() on the contextmenu event to create a custom menu, however they have to implement custom logic to try to detect under what circumstances it should close. There are many scenarios under which a contextmenu should be closed, that would be easier to handle given a single event to listen for:

- Escape key pressed
- When focusing any other window
- Clicking outside of the browser window
- When interacting with touch it is common to initiate a contextmenu after a long press. However, if the item being pressed is also draggable than a subsequent drag of the finger can be used to initiate a drag which implicitly cancels the contextmenu.

I propose adding a contextmenuclose (or contextmenucancel or contextmenudismiss) event which will be dispatched under the conditions when the platform would close a native contextmenu.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/uievents/issues/309

Received on Thursday, 26 August 2021 17:38:31 UTC