mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fix closing of context menu on FF66, closes #468
This commit is contained in:
		@@ -1,5 +1,7 @@
 | 
				
			|||||||
const $contextMenuContainer = $("#context-menu-container");
 | 
					const $contextMenuContainer = $("#context-menu-container");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let dateContextMenuOpenedMs = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function initContextMenu(event, contextMenuItems, selectContextMenuItem) {
 | 
					function initContextMenu(event, contextMenuItems, selectContextMenuItem) {
 | 
				
			||||||
    event.stopPropagation();
 | 
					    event.stopPropagation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -73,6 +75,8 @@ function initContextMenu(event, contextMenuItems, selectContextMenuItem) {
 | 
				
			|||||||
        top = event.pageY - 10;
 | 
					        top = event.pageY - 10;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dateContextMenuOpenedMs = Date.now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $contextMenuContainer.css({
 | 
					    $contextMenuContainer.css({
 | 
				
			||||||
        display: "block",
 | 
					        display: "block",
 | 
				
			||||||
        top: top,
 | 
					        top: top,
 | 
				
			||||||
@@ -80,8 +84,18 @@ function initContextMenu(event, contextMenuItems, 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);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user