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).
This adds the
useModal
option, defaults totrue
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 waspropagated
, and noclick
was sent since the followingmouseup
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).