diff --git a/frontend/app/components/context-menus/context-menu.service.ts b/frontend/app/components/context-menus/context-menu.service.ts index 6381c83afc..2a4968a993 100644 --- a/frontend/app/components/context-menus/context-menu.service.ts +++ b/frontend/app/components/context-menus/context-menu.service.ts @@ -38,6 +38,10 @@ export class ContextMenuService { private active_menu:ContextMenu|null; private repositionCurrentElement:Function|null; + // RR: Ugly flag to avoid bug in Firefox: + // right-click immediately triggered $window.click -> close() event + private tempDisableGlobalClose = false; + constructor(public $window:ng.IWindowService, public $injector:ng.auto.IInjectorService, public $q:ng.IQService, @@ -56,7 +60,11 @@ export class ContextMenuService { Mousetrap.bind('escape', () => this.close()); // Listen to any click and close the active context menu - jQuery($window).click(() => this.close()); + jQuery($window).click(() => { + if (!this.tempDisableGlobalClose) { + this.close(); + } + }); } @@ -76,6 +84,8 @@ export class ContextMenuService { } public activate(contextMenuName:string, event:Event, locals:Object, positionArgs?:any) { + this.tempDisableGlobalClose = true; + let deferred = this.$q.defer(); let target = jQuery(event.target); let contextMenu:ContextMenu = this.$injector.get(contextMenuName); @@ -103,6 +113,8 @@ export class ContextMenuService { this.repositionCurrentElement!(); menuElement.css('visibility', 'visible'); deferred.resolve(menuElement); + + this.tempDisableGlobalClose = false; }); });