From 3ebf3fdb6789ee5bccb993f1028d4d64111bf09f Mon Sep 17 00:00:00 2001 From: brahim <92426196+BrhmDev@users.noreply.github.com> Date: Fri, 20 Sep 2024 20:42:30 +0200 Subject: [PATCH] Remove hardcoded popup ids from keepSidebarVisibleOnContextMenu --- src/browser/base/content/ZenUIManager.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/browser/base/content/ZenUIManager.mjs b/src/browser/base/content/ZenUIManager.mjs index 037b13408..13b6a34cc 100644 --- a/src/browser/base/content/ZenUIManager.mjs +++ b/src/browser/base/content/ZenUIManager.mjs @@ -151,7 +151,7 @@ var gZenCompactModeManager = { Services.prefs.addObserver('zen.view.compact', this._updateEvent.bind(this)); Services.prefs.addObserver('zen.view.compact.toolbar-flash-popup.duration', this._updatedSidebarFlashDuration.bind(this)); - this.sidebar.addEventListener('contextmenu', this.keepSidebarVisibleOnContextMenu.bind(this)); + addEventListener('popupshowing', this.keepSidebarVisibleOnContextMenu.bind(this)); }, get prefefence() { @@ -210,7 +210,10 @@ var gZenCompactModeManager = { }, this.flashSidebarDuration); }, - keepSidebarVisibleOnContextMenu() { + keepSidebarVisibleOnContextMenu(event) { + if (!this.sidebar.contains(event.explicitOriginalTarget)) { + return; + } this.sidebar.setAttribute('has-popup-menu', ''); /* If the cursor is on the popup when it hides, the :hover effect will not be reapplied to the sidebar until the cursor moves, to mitigate this: Wait for mousemove when popup item selected @@ -227,8 +230,8 @@ var gZenCompactModeManager = { addEventListener('mousemove', this.__removeHasPopupAttribute, {once: true}); } } - const removeHasPopupOnPopupHidden = (event) => { - if (['toolbar-context-menu', 'tabContextMenu'].includes(event.target.id)) { + const removeHasPopupOnPopupHidden = (hiddenEvent) => { + if (event.target === hiddenEvent.target) { removeEventListener('click', waitForMouseMoveOnPopupSelect); removeEventListener('popuphidden', removeHasPopupOnPopupHidden); this.__removeHasPopupAttribute();