mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix closing of context menu on FF66, closes #468
(cherry picked from commit 3c56d29fca16911dc587c5ab6ed221df9005895a)
This commit is contained in:
parent
b4c6d9f800
commit
27cee1cf33
@ -1,5 +1,7 @@
|
|||||||
const $contextMenuContainer = $("#context-menu-container");
|
const $contextMenuContainer = $("#context-menu-container");
|
||||||
|
|
||||||
|
let dateContextMenuOpenedMs = 0;
|
||||||
|
|
||||||
function initContextMenu(event, itemContainer, selectContextMenuItem) {
|
function initContextMenu(event, itemContainer, selectContextMenuItem) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
@ -55,6 +57,8 @@ function initContextMenu(event, itemContainer, selectContextMenuItem) {
|
|||||||
top = event.pageY - 10;
|
top = event.pageY - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dateContextMenuOpenedMs = Date.now();
|
||||||
|
|
||||||
$contextMenuContainer.css({
|
$contextMenuContainer.css({
|
||||||
display: "block",
|
display: "block",
|
||||||
top: top,
|
top: top,
|
||||||
@ -62,8 +66,18 @@ function initContextMenu(event, itemContainer, selectContextMenuItem) {
|
|||||||
}).addClass("show");
|
}).addClass("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).click(() => $contextMenuContainer.hide());
|
$(document).click(() => hideContextMenu());
|
||||||
|
|
||||||
|
function hideContextMenu() {
|
||||||
|
// this date checking comes from change in FF66 - https://github.com/zadam/trilium/issues/468
|
||||||
|
// "contextmenu" event also triggers "click" event which depending on the timing can close just opened context menu
|
||||||
|
// we might filter out right clicks, but then it's better if even right clicks close the context menu
|
||||||
|
if (Date.now() - dateContextMenuOpenedMs > 300) {
|
||||||
|
$contextMenuContainer.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
initContextMenu
|
initContextMenu,
|
||||||
|
hideContextMenu
|
||||||
}
|
}
|
@ -417,6 +417,9 @@ function initFancyTree(tree) {
|
|||||||
const node = data.node;
|
const node = data.node;
|
||||||
const noteId = node.data.noteId;
|
const noteId = node.data.noteId;
|
||||||
|
|
||||||
|
// click event won't propagate so let's close context menu manually
|
||||||
|
contextMenuWidget.hideContextMenu();
|
||||||
|
|
||||||
setCurrentNotePathToHash(node);
|
setCurrentNotePathToHash(node);
|
||||||
|
|
||||||
noteDetailService.switchToNote(noteId);
|
noteDetailService.switchToNote(noteId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user