From 98a6670cb4a43936f50421e518fb417120ee0151 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 10 Oct 2019 19:34:55 +0200 Subject: [PATCH] prevent default context menu on tab right click, closes #656 --- package-lock.json | 2 +- src/public/javascripts/services/link.js | 8 ++++---- src/public/javascripts/services/note_detail.js | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50654a1a0..3f9dfde75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trilium", - "version": "0.35.1", + "version": "0.35.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/public/javascripts/services/link.js b/src/public/javascripts/services/link.js index 1d66bd27e..2b89c064c 100644 --- a/src/public/javascripts/services/link.js +++ b/src/public/javascripts/services/link.js @@ -113,7 +113,7 @@ function addTextToEditor(text) { } } -function tabContextMenu(e) { +function newTabContextMenu(e) { const $link = $(e.target); const notePath = getNotePathFromLink($link); @@ -138,9 +138,9 @@ function tabContextMenu(e) { }); } -$(document).on('contextmenu', '.note-detail-text a', tabContextMenu); -$(document).on('contextmenu', "a[data-action='note']", tabContextMenu); -$(document).on('contextmenu', ".note-detail-render a", tabContextMenu); +$(document).on('contextmenu', '.note-detail-text a', newTabContextMenu); +$(document).on('contextmenu', "a[data-action='note']", newTabContextMenu); +$(document).on('contextmenu', ".note-detail-render a", newTabContextMenu); // when click on link popup, in case of internal link, just go the the referenced note instead of default behavior // of opening the link in new window/tab diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js index 6912d9f27..49e2e3211 100644 --- a/src/public/javascripts/services/note_detail.js +++ b/src/public/javascripts/services/note_detail.js @@ -385,6 +385,8 @@ tabRow.addListener('tabRemove', async ({ detail }) => { }); $(tabRow.el).on('contextmenu', '.note-tab', e => { + e.preventDefault(); + const tab = $(e.target).closest(".note-tab"); contextMenuService.initContextMenu(e, {