react-contexify icon indicating copy to clipboard operation
react-contexify copied to clipboard

Is there a way to disable the custom context menu for a tag

Open JoeGaffney opened this issue 1 year ago • 1 comments

Is there a way to disable the context menu on img tag?

For example inside a component that has a custom context menu there is some img tags that we want the default browser context menu.

JoeGaffney avatar Nov 07 '23 18:11 JoeGaffney

Found out how you can do it on the showMenu function if anyone stumbles upon this query

function showMenu(e) {
    // Prevent the context menu from appearing for certain elements
    if (e.target.tagName === "IMG" || e.target.tagName === "VIDEO" || e.target.tagName === "A") {
      return;
    } else {
      e.stopPropagation();
      show({
        event: e,
        props: {},
        id: GetMenuId(),
      });
    }
  }

JoeGaffney avatar Nov 07 '23 18:11 JoeGaffney