Bug 1933592 - Hide the sidebar launcher if the sidebar toolbar button is removed r=sidebar-reviewers,jsudiaman
Differential Revision: https://phabricator.services.mozilla.com/D231749
This commit is contained in:
@@ -205,9 +205,24 @@ export class SidebarState {
|
||||
return this.#props.launcherVisible;
|
||||
}
|
||||
|
||||
updateVisibility(visible, openedByToolbarButton = false) {
|
||||
updateVisibility(
|
||||
visible,
|
||||
openedByToolbarButton = false,
|
||||
onToolbarButtonRemoval = false
|
||||
) {
|
||||
switch (this.revampVisibility) {
|
||||
case "hide-sidebar":
|
||||
if (onToolbarButtonRemoval) {
|
||||
// If we are hiding the sidebar because we removed the toolbar button, close everything
|
||||
this.#previousLauncherVisible = false;
|
||||
this.launcherVisible = false;
|
||||
this.launcherExpanded = true;
|
||||
|
||||
if (this.panelOpen) {
|
||||
this.#controller.hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!openedByToolbarButton && !visible && this.panelOpen) {
|
||||
// no-op to handle the case when a user changes the visibility setting via the
|
||||
// customize panel, we don't want to close anything on them.
|
||||
|
||||
@@ -349,6 +349,8 @@ var SidebarController = {
|
||||
this._handleLauncherResize(entry)
|
||||
);
|
||||
|
||||
CustomizableUI.addListener(this);
|
||||
|
||||
if (this.sidebarRevampEnabled) {
|
||||
if (!customElements.get("sidebar-main")) {
|
||||
ChromeUtils.importESModule(
|
||||
@@ -455,6 +457,8 @@ var SidebarController = {
|
||||
Services.obs.removeObserver(this, "tabstrip-orientation-change");
|
||||
delete this._tabstripOrientationObserverAdded;
|
||||
|
||||
CustomizableUI.removeListener(this);
|
||||
|
||||
if (this._observer) {
|
||||
this._observer.disconnect();
|
||||
this._observer = null;
|
||||
@@ -1684,6 +1688,13 @@ var SidebarController = {
|
||||
}
|
||||
},
|
||||
|
||||
onWidgetRemoved(aWidgetId) {
|
||||
if (aWidgetId == "sidebar-button") {
|
||||
Services.prefs.setStringPref("sidebar.visibility", "hide-sidebar");
|
||||
this._state.updateVisibility(false, false, true);
|
||||
}
|
||||
},
|
||||
|
||||
toggleTabstrip() {
|
||||
let toVerticalTabs = CustomizableUI.verticalTabsEnabled;
|
||||
let tabStrip = gBrowser.tabContainer;
|
||||
|
||||
@@ -294,6 +294,13 @@ add_task(async function test_sidebar_button_runtime_pref_enabled() {
|
||||
CustomizableUI.AREA_NAVBAR,
|
||||
"The sidebar button is in the nav-bar"
|
||||
);
|
||||
|
||||
// When the button was removed, "hide-sidebar" was set automatically. Revert for the next test.
|
||||
// Expanded is the default when "hide-sidebar" is set - click the button to revert for the next test.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[SIDEBAR_VISIBILITY_PREF, "always-show"]],
|
||||
});
|
||||
button.click();
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user