swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.25k stars 744 forks source link

Make the modal layer let click events passthrough #760

Open Speedphoenix opened 2 years ago

Speedphoenix commented 2 years ago

This adds the useModal option, defaults to true for the existing behaviour.

With useModal set to false, rather than creating a hidden layer behind the contextmenu to capture closing clicks, uses document.addeventlistener in capture mode.

This allows for propagating click events when clicking in empty space to close the contextmenu (before, only the mousedown event was propagated, and no click was sent since the following mouseup would not be on the same element)

Note useModal = false might break on older browsers, or some features might not work with it anymore (unlikely though).