From f10d4259db6e4ffbb0d265e17d235022914580b4 Mon Sep 17 00:00:00 2001 From: EnderDev Date: Sat, 16 Dec 2023 21:45:23 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Only=20toggle=20active=20s?= =?UTF-8?q?tates=20on=20browsers=20when=20tab=20fully=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/tabs/BrowserTabs.sys.mjs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/components/tabs/BrowserTabs.sys.mjs b/components/tabs/BrowserTabs.sys.mjs index ea34c014ef..ba6aa766ef 100644 --- a/components/tabs/BrowserTabs.sys.mjs +++ b/components/tabs/BrowserTabs.sys.mjs @@ -75,11 +75,6 @@ BrowserTabs.prototype = { /** @type {number} */ _uniquePanelIdCounter: null, - /** A mapping between webContentsId -> BrowserTab - * @type {Map} - * */ - _tabs: new Map(), - /** * A mapping between BrowserTab -> TabProgressListener * @type {Map} @@ -138,11 +133,17 @@ BrowserTabs.prototype = { set selectedTab(tab) { /** @type {BrowserTab} */ const oldTab = this._selectedTab; - if (oldTab && oldTab.webContentsPanel) + + const isSameTab = oldTab === tab; + + if (!isSameTab && oldTab && oldTab.webContentsPanel) oldTab.webContentsPanel.removeAttribute("visible"); if (oldTab) { - if (this._isWebContentsBrowserElement(oldTab.webContents)) { + if ( + !isSameTab && + this._isWebContentsBrowserElement(oldTab.webContents) + ) { /** @type {ChromeBrowser} */ ( oldTab.webContents ).docShellIsActive = false; @@ -155,7 +156,7 @@ BrowserTabs.prototype = { ); } - if (this._isWebContentsBrowserElement(tab.webContents)) { + if (!isSameTab && this._isWebContentsBrowserElement(tab.webContents)) { const browser = /** @type {ChromeBrowser} */ (tab.webContents); browser.docShellIsActive = true; @@ -164,7 +165,7 @@ BrowserTabs.prototype = { this._selectedTab = tab; - if (tab.webContentsPanel) { + if (!isSameTab && tab.webContentsPanel) { tab.webContentsPanel.toggleAttribute("visible", true); }