This is required to ensure compatibility with the functionality of legacy user panels.
scrollDisable();
this.container.hidden = false;
- this.provider.refresh();
+ this.provider.wakeup();
this.getFocusTrap().activate();
}
this.container.hidden = true;
this.getFocusTrap().deactivate();
+
+ this.provider.sleep();
}
toggle(): void {
return this.mainMenu;
}
- refresh(): void {
+ sleep(): void {
+ /* Does nothing */
+ }
+
+ wakeup(): void {
/* Does nothing */
}
getMenuButton(): HTMLElement;
- refresh(): void;
+ sleep(): void;
+
+ wakeup(): void;
}
};
export class PageMenuUser implements PageMenuProvider {
+ private activeTab?: Tab = undefined;
private readonly callbackOpen: CallbackOpen;
private readonly container: PageMenuContainer;
private readonly legacyUserPanels = new Map<Tab, LegacyUserPanelApi>();
return this.userMenu;
}
- refresh(): void {
- const activeTab = this.tabs.find((element) => element.getAttribute("aria-selected") === "true");
- if (activeTab === undefined) {
- this.openNotifications();
- } else {
+ sleep(): void {
+ if (this.activeTab) {
+ this.closeTab(this.activeTab);
+ }
+ }
+
+ wakeup(): void {
+ if (this.activeTab) {
// The UI elements in the tab panel are shared and can appear in a different
// context. The element might have been moved elsewhere while the menu was
// closed.
- this.attachViewToPanel(activeTab);
+ this.openTab(this.activeTab);
+ } else {
+ this.openNotifications();
}
}
}
private openTab(tab: Tab): void {
- if (tab.getAttribute("aria-selected") === "true") {
- return;
- }
-
- const activeTab = this.tabs.find((element) => element.getAttribute("aria-selected") === "true");
- if (activeTab) {
- activeTab.setAttribute("aria-selected", "false");
- activeTab.tabIndex = -1;
-
- const activePanel = this.tabPanels.get(activeTab)!;
- activePanel.hidden = true;
- }
+ this.closeActiveTab();
tab.setAttribute("aria-selected", "true");
tab.tabIndex = 0;
}
this.attachViewToPanel(tab);
+
+ this.activeTab = tab;
+ }
+
+ private closeActiveTab(): void {
+ if (!this.activeTab) {
+ return;
+ }
+
+ this.closeTab(this.activeTab);
+
+ this.activeTab = undefined;
+ }
+
+ private closeTab(tab: Tab): void {
+ tab.setAttribute("aria-selected", "false");
+ tab.tabIndex = -1;
+
+ const tabPanel = this.tabPanels.get(tab)!;
+ tabPanel.hidden = true;
+
+ const legacyPanel = this.legacyUserPanels.get(tab);
+ if (legacyPanel) {
+ legacyPanel.close();
+ }
}
private attachViewToPanel(tab: Tab): void {
(0, Screen_1.pageOverlayOpen)();
(0, Screen_1.scrollDisable)();
this.container.hidden = false;
- this.provider.refresh();
+ this.provider.wakeup();
this.getFocusTrap().activate();
}
close() {
(0, Screen_1.scrollEnable)();
this.container.hidden = true;
this.getFocusTrap().deactivate();
+ this.provider.sleep();
}
toggle() {
if (this.container.hidden) {
getMenuButton() {
return this.mainMenu;
}
- refresh() {
+ sleep() {
+ /* Does nothing */
+ }
+ wakeup() {
/* Does nothing */
}
buildMainMenu() {
EventHandler = (0, tslib_1.__importStar)(EventHandler);
class PageMenuUser {
constructor() {
+ this.activeTab = undefined;
this.legacyUserPanels = new Map();
this.userMenuProviders = new Map();
this.tabPanels = new Map();
getMenuButton() {
return this.userMenu;
}
- refresh() {
- const activeTab = this.tabs.find((element) => element.getAttribute("aria-selected") === "true");
- if (activeTab === undefined) {
- this.openNotifications();
+ sleep() {
+ if (this.activeTab) {
+ this.closeTab(this.activeTab);
}
- else {
+ }
+ wakeup() {
+ if (this.activeTab) {
// The UI elements in the tab panel are shared and can appear in a different
// context. The element might have been moved elsewhere while the menu was
// closed.
- this.attachViewToPanel(activeTab);
+ this.openTab(this.activeTab);
+ }
+ else {
+ this.openNotifications();
}
}
openNotifications() {
this.openTab(notifications);
}
openTab(tab) {
- if (tab.getAttribute("aria-selected") === "true") {
- return;
- }
- const activeTab = this.tabs.find((element) => element.getAttribute("aria-selected") === "true");
- if (activeTab) {
- activeTab.setAttribute("aria-selected", "false");
- activeTab.tabIndex = -1;
- const activePanel = this.tabPanels.get(activeTab);
- activePanel.hidden = true;
- }
+ this.closeActiveTab();
tab.setAttribute("aria-selected", "true");
tab.tabIndex = 0;
const tabPanel = this.tabPanels.get(tab);
tab.focus();
}
this.attachViewToPanel(tab);
+ this.activeTab = tab;
+ }
+ closeActiveTab() {
+ if (!this.activeTab) {
+ return;
+ }
+ this.closeTab(this.activeTab);
+ this.activeTab = undefined;
+ }
+ closeTab(tab) {
+ tab.setAttribute("aria-selected", "false");
+ tab.tabIndex = -1;
+ const tabPanel = this.tabPanels.get(tab);
+ tabPanel.hidden = true;
+ const legacyPanel = this.legacyUserPanels.get(tab);
+ if (legacyPanel) {
+ legacyPanel.close();
+ }
}
attachViewToPanel(tab) {
const origin = tab.dataset.origin;