Skip to content

bug?: defining left click as trigger type triggers "oncontextmenu" of trigger button #754

Open
@arashdalir

Description

@arashdalir

I have encountered an unexpected side-effect of the left-click handling in the code: we have a trigger button inside a slick-grid table structure, our slick-grid cells have a handler for onContextMenu and we are now facing a major issue with the trigger button! it's calling the slick-grid handler instead of calling the contextMenu creator.

following GIF shows the issue. the yellow clicks are left-click, the red ones are right-click...

contextMenu-leftClick

reason for it is the code below. clicking the trigger button is calling the contextMenu event, which in return triggers the onContextMenu function defined later on in our slick-grid section.

any suggestions how to avoid this?

  • one solution is to detect that the onContextMenu was triggered artificially in the slick-grid code and not to continue that function. this would require that the code knows that the trigger (event target) is a contextMenu object. I have not been able to find any plugin command or helper which would facilitate this.
  • another and well, a better solution is to rewrite the code below to avoid calling contextMenu event! technically, it should be possible to define 2 different sets of actions for left-clicking or right-clicking an element and this piece of code is forbidding it...
//jquery.contextMenu.js:351 - v2.9.2
// contextMenu left-click trigger
click: function (e) {
  e.preventDefault();
  e.stopImmediatePropagation();
  $(this).trigger($.Event('contextmenu', {data: e.data, pageX: e.pageX, pageY: e.pageY}));
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions