swisnl / jQuery-contextMenu

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

Option to use the native context menu for some descendants of element specified by selector #658

Closed mattmccutchen closed 5 years ago

mattmccutchen commented 6 years ago

A feature proposal: I'd like an option to use the native context menu for some descendants of the element specified by the selector. A few ideas of how this could be specified: a selector for those descendants, a callback that decides whether a given event should trigger the custom or native context menu, or an option that effectively excludes all descendants and applies the custom menu only to events whose original target matches the selector. Note that returning false from the build callback results in no menu at all, not the native menu, and I imagine we shouldn't change that.

I am building a spreadsheet tool with jQuery-contextMenu enabled on the main spreadsheet area, but the spreadsheet may contain hyperlinks, and I want right-clicks on those hyperlinks to open the native context menu so the user can use the "Open in new tab" command. For now, I implemented this by brute force by registering an event handler that runs before jQuery-contextMenu's handler and calls stopImmediatePropagation, since I am using React (reference); in other scenarios, the necessary technique may be different. I'm satisfied with this solution, but I thought I would log an issue anyway.

mattmccutchen commented 5 years ago

Duplicate of #669.