mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	Retrigger the opening animation when repositioning menus that are already open
This commit is contained in:
		| @@ -12,6 +12,12 @@ class ContextMenu { | ||||
|     async show(options) { | ||||
|         this.options = options; | ||||
|  | ||||
|         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. | ||||
|             await this.hide(); | ||||
|         } | ||||
|  | ||||
|         this.$widget.empty(); | ||||
|  | ||||
|         this.addItems(this.$widget, options.items); | ||||
| @@ -143,18 +149,26 @@ class ContextMenu { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     hide() { | ||||
|     async hide() { | ||||
|         // 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 the 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() - this.dateContextMenuOpenedMs > 300) { | ||||
|             // seems like if we hide the menu immediately, some clicks can get propagated to the underlying component | ||||
|             // see https://github.com/zadam/trilium/pull/3805 for details | ||||
|             setTimeout(() => this.$widget.hide(), 100); | ||||
|             await timeout(100); | ||||
|             this.$widget.removeClass("show"); | ||||
|             this.$widget.hide() | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| function timeout(ms) { | ||||
|     return new Promise((accept, reject) => { | ||||
|         setTimeout(accept, ms); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| const contextMenu = new ContextMenu(); | ||||
|  | ||||
| export default contextMenu; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user