diff --git a/shared/components/rstack-app-switcher.ts b/shared/components/rstack-app-switcher.ts index 604d45b..382cc46 100644 --- a/shared/components/rstack-app-switcher.ts +++ b/shared/components/rstack-app-switcher.ts @@ -557,6 +557,12 @@ export class RStackAppSwitcher extends HTMLElement { this.#render(); } + /** Open the sidebar programmatically (used by tab bar [+] button) */ + open() { + this.#isOpen = true; + this.#render(); + } + #getSpaceSlug(): string { // Read from the space switcher or URL const spaceSwitcher = document.querySelector("rstack-space-switcher"); diff --git a/shared/components/rstack-tab-bar.ts b/shared/components/rstack-tab-bar.ts index dc4b463..abda7dc 100644 --- a/shared/components/rstack-tab-bar.ts +++ b/shared/components/rstack-tab-bar.ts @@ -1085,16 +1085,18 @@ export class RStackTabBar extends HTMLElement { }); }); - // Add button — click + touch support + // Add button — open the header's app-switcher sidebar const addBtn = this.#shadow.getElementById("add-btn"); - const toggleAddMenu = (e: Event) => { + const openAppSwitcher = (e: Event) => { e.stopPropagation(); e.preventDefault(); - this.#addMenuOpen = !this.#addMenuOpen; - this.#render(); + const switcher = document.querySelector("rstack-app-switcher") as any; + if (switcher?.open) { + switcher.open(); + } }; - addBtn?.addEventListener("click", toggleAddMenu); - addBtn?.addEventListener("touchend", toggleAddMenu); + addBtn?.addEventListener("click", openAppSwitcher); + addBtn?.addEventListener("touchend", openAppSwitcher); // Add menu items — click + touch support this.#shadow.querySelectorAll(".add-menu-item").forEach(item => {