Bug 1933818 - Sidebar panel keyboard shortcuts should hide the sidebar r=sidebar-reviewers,nsharpley,jsudiaman

*Update SidebarState logic so that opening and closing panels reverts to the correct launcher visibility for the show and hide setting
*Add a test

Differential Revision: https://phabricator.services.mozilla.com/D231838
This commit is contained in:
Sarah Clements
2024-12-13 13:24:28 +00:00
parent cd2f100c8e
commit 999958fa5a
4 changed files with 58 additions and 25 deletions

View File

@@ -27,6 +27,7 @@ export class SidebarCustomize extends SidebarPage {
VISIBILITY_SETTING_PREF,
"always-show"
);
this.boundObserve = (...args) => this.observe(...args);
}
static properties = {
@@ -47,6 +48,7 @@ export class SidebarCustomize extends SidebarPage {
this.getWindow().addEventListener("SidebarItemAdded", this);
this.getWindow().addEventListener("SidebarItemChanged", this);
this.getWindow().addEventListener("SidebarItemRemoved", this);
Services.prefs.addObserver(VISIBILITY_SETTING_PREF, this.boundObserve);
}
disconnectedCallback() {
@@ -54,6 +56,22 @@ export class SidebarCustomize extends SidebarPage {
this.getWindow().removeEventListener("SidebarItemAdded", this);
this.getWindow().removeEventListener("SidebarItemChanged", this);
this.getWindow().removeEventListener("SidebarItemRemoved", this);
Services.prefs.removeObserver(VISIBILITY_SETTING_PREF, this.boundObserve);
}
observe(subject, topic, prefName) {
switch (topic) {
case "nsPref:changed":
switch (prefName) {
case VISIBILITY_SETTING_PREF:
this.visibility = Services.prefs.getStringPref(
VISIBILITY_SETTING_PREF,
"always-show"
);
break;
}
break;
}
}
get sidebarLauncher() {