forked from mirrors/gecko-dev
Bug 1917632 - Apply the sidebar revamp in the same window that pref is enabled in a=dmeehan
`adoptFromWindow` sets the sidebar width based on the "opener" window. If the opener does not have a sidebar, no width is remembered. Previously, flipping the sidebar revamp pref required opening a new window to see the revamped sidebar, and hence meant the opener did not have a sidebar. This patch ensures the revamp is applied in the current/opener window and hence the width of the sidebar opened in that window is used to determine the width of the sidebar in future windows opened. This should resolve the issue some users have found when closing the browser via the X button and reopening the browser doesn't remember the sidebar width. Differential Revision: https://phabricator.services.mozilla.com/D226942
This commit is contained in:
parent
d3ce586511
commit
2afdb99960
1 changed files with 48 additions and 1 deletions
|
|
@ -57,7 +57,10 @@ var SidebarController = {
|
|||
if (this._sidebars) {
|
||||
return this._sidebars;
|
||||
}
|
||||
return this.generateSidebarsMap();
|
||||
},
|
||||
|
||||
generateSidebarsMap() {
|
||||
this._sidebars = new Map([
|
||||
[
|
||||
"viewHistorySidebar",
|
||||
|
|
@ -190,6 +193,13 @@ var SidebarController = {
|
|||
return this._inited;
|
||||
},
|
||||
|
||||
get sidebarMain() {
|
||||
if (!this._sidebarMain) {
|
||||
this._sidebarMain = document.querySelector("sidebar-main");
|
||||
}
|
||||
return this._sidebarMain;
|
||||
},
|
||||
|
||||
async init() {
|
||||
this._box = document.getElementById("sidebar-box");
|
||||
this._splitter = document.getElementById("sidebar-splitter");
|
||||
|
|
@ -415,6 +425,42 @@ var SidebarController = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show/hide new sidebar based on sidebar.revamp pref
|
||||
*/
|
||||
async toggleRevampSidebar() {
|
||||
await this.promiseInitialized;
|
||||
let wasOpen = this.isOpen;
|
||||
if (wasOpen) {
|
||||
this.hide();
|
||||
}
|
||||
// Reset sidebars map but preserve any existing extensions
|
||||
let extensionsArr = [];
|
||||
for (const [commandID, sidebar] of this.sidebars.entries()) {
|
||||
if (sidebar.hasOwnProperty("extensionId")) {
|
||||
extensionsArr.push({ commandID, sidebar });
|
||||
}
|
||||
}
|
||||
this.sidebars = this.generateSidebarsMap();
|
||||
for (const extension of extensionsArr) {
|
||||
this.sidebars.set(extension.commandID, extension.sidebar);
|
||||
}
|
||||
if (!this.sidebarRevampEnabled) {
|
||||
this.sidebarMain.hidden = true;
|
||||
document.getElementById("sidebar-header").hidden = false;
|
||||
// Disable vertical tabs if revamped sidebar is turned off
|
||||
if (this.sidebarVerticalTabsEnabled) {
|
||||
Services.prefs.setBoolPref("sidebar.verticalTabs", false);
|
||||
}
|
||||
} else {
|
||||
this.sidebarMain.hidden = false;
|
||||
}
|
||||
if (!this._sidebars.get(this.lastOpenedId)) {
|
||||
this.lastOpenedId = this.DEFAULT_SIDEBAR_ID;
|
||||
}
|
||||
await this.init();
|
||||
},
|
||||
|
||||
/**
|
||||
* Try and adopt the status of the sidebar from another window.
|
||||
*
|
||||
|
|
@ -1028,5 +1074,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
SidebarController,
|
||||
"sidebarRevampEnabled",
|
||||
"sidebar.revamp",
|
||||
false
|
||||
false,
|
||||
SidebarController.toggleRevampSidebar.bind(SidebarController)
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue