mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	feat(context_menu): dismiss note tooltip when a context menu is shown
This commit is contained in:
		
							parent
							
								
									d814a4d49f
								
							
						
					
					
						commit
						0288ebcad9
					
				| @ -1,5 +1,6 @@ | ||||
| import type { CommandNames } from "../components/app_context.js"; | ||||
| import keyboardActionService from "../services/keyboard_actions.js"; | ||||
| import note_tooltip from "../services/note_tooltip.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| interface ContextMenuOptions<T extends CommandNames> { | ||||
| @ -57,6 +58,8 @@ class ContextMenu { | ||||
|     async show<T extends CommandNames>(options: ContextMenuOptions<T>) { | ||||
|         this.options = options; | ||||
| 
 | ||||
|         note_tooltip.dismissAllTooltips(); | ||||
| 
 | ||||
|         if (this.$widget.hasClass("show")) { | ||||
|             // The menu is already visible. Hide the menu then open it again
 | ||||
|             // at the new location to re-trigger the opening animation.
 | ||||
|  | ||||
| @ -18,11 +18,11 @@ function setupGlobalTooltip() { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         cleanUpTooltips(); | ||||
|         dismissAllTooltips(); | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| function cleanUpTooltips() { | ||||
| function dismissAllTooltips() { | ||||
|     $(".note-tooltip").remove(); | ||||
| } | ||||
| 
 | ||||
| @ -102,12 +102,12 @@ async function mouseEnterHandler(this: HTMLElement) { | ||||
|             customClass: linkId | ||||
|         }); | ||||
| 
 | ||||
|         cleanUpTooltips(); | ||||
|         dismissAllTooltips(); | ||||
|         $(this).tooltip("show"); | ||||
| 
 | ||||
|         // Dismiss the tooltip immediately if a link was clicked inside the tooltip.
 | ||||
|         $(`.${tooltipClass} a`).on("click", (e) => { | ||||
|             cleanUpTooltips(); | ||||
|             dismissAllTooltips(); | ||||
|         }); | ||||
| 
 | ||||
|         // the purpose of the code below is to:
 | ||||
| @ -117,7 +117,7 @@ async function mouseEnterHandler(this: HTMLElement) { | ||||
|         const checkTooltip = () => { | ||||
|             if (!$(this).filter(":hover").length && !$(`.${linkId}:hover`).length) { | ||||
|                 // cursor is neither over the link nor over the tooltip, user likely is not interested
 | ||||
|                 cleanUpTooltips(); | ||||
|                 dismissAllTooltips(); | ||||
|             } else { | ||||
|                 setTimeout(checkTooltip, 1000); | ||||
|             } | ||||
| @ -172,5 +172,6 @@ function renderFootnote($link: JQuery<HTMLElement>, url: string) { | ||||
| 
 | ||||
| export default { | ||||
|     setupGlobalTooltip, | ||||
|     setupElementTooltip | ||||
|     setupElementTooltip, | ||||
|     dismissAllTooltips | ||||
| }; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran