Skip to content

Commit

Permalink
⚡️ Only toggle active states on browsers when tab fully changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kierandrewett committed Dec 16, 2023
1 parent bee7cce commit f10d425
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions components/tabs/BrowserTabs.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ BrowserTabs.prototype = {
/** @type {number} */
_uniquePanelIdCounter: null,

/** A mapping between webContentsId -> BrowserTab
* @type {Map<number, BrowserTab>}
* */
_tabs: new Map(),

/**
* A mapping between BrowserTab -> TabProgressListener
* @type {Map<BrowserTab, TabProgressListener>}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -164,7 +165,7 @@ BrowserTabs.prototype = {

this._selectedTab = tab;

if (tab.webContentsPanel) {
if (!isSameTab && tab.webContentsPanel) {
tab.webContentsPanel.toggleAttribute("visible", true);
}

Expand Down

0 comments on commit f10d425

Please sign in to comment.