Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): ignore the collapsed flag in the phone drawer
Yudhi Armyndharis4cbc64fe0e44
diff --git a/dashboard/src/components/Layout.test.ts b/dashboard/src/components/Layout.test.tsindex 983a0845e..6649a457c 100644--- a/dashboard/src/components/Layout.test.ts+++ b/dashboard/src/components/Layout.test.ts@@ -84,6 +84,35 @@ test('the theme button can return to following the system', () => {assert.equal(localStorage.getItem('openwa_theme'), 'system');});+// Collapsing is a desktop preference: the phone drawer has no collapse control, so a flag left over from a wider+// window must not strip its labels, and the window widening again must find the preference where it was left.+test('a collapsed sidebar shows its labels in the phone drawer and collapses again on desktop', () => {+ const width = window.innerWidth;+ try {+ const { container } = renderLayout();+ const sidebar = container.querySelector('aside.sidebar')!;+ rtl.fireEvent.click(container.querySelector('.collapse-toggle')!);+ assert.ok(sidebar.classList.contains('collapsed'));+ assert.equal(container.querySelectorAll('.nav-item span').length, 0, 'the collapsed desktop sidebar shows labels');++ window.innerWidth = 500;+ rtl.fireEvent(window, new window.Event('resize'));+ assert.ok(sidebar.classList.contains('mobile'));+ assert.ok(!sidebar.classList.contains('collapsed'), 'the phone drawer kept the collapsed class');+ const labels = Array.from(container.querySelectorAll('.nav-item')).map(item => item.textContent);+ assert.ok(labels.length > 0 && labels.every(label => label), `the drawer entries read ${JSON.stringify(labels)}`);+ assert.ok(container.querySelector('.sidebar-brand'), 'the drawer has no brand');+ assert.equal(container.querySelector('.logout-btn')!.textContent, 'Logout');+ assert.ok(!container.querySelector('main')!.classList.contains('expanded'));++ window.innerWidth = width;+ rtl.fireEvent(window, new window.Event('resize'));+ assert.ok(sidebar.classList.contains('collapsed'), 'the desktop preference was lost');+ } finally {+ window.innerWidth = width;+ }+});+// The key management, infrastructure and plugin routes refuse a key restricted to selected sessions, whatever// its role, and every refusal lands in the audit log as a failed attempt.test('an admin key scoped to sessions is not offered the pages that refuse it', async () => {diff --git a/dashboard/src/components/Layout.tsx b/dashboard/src/components/Layout.tsxindex a4513c428..8c1b9b9ec 100644--- a/dashboard/src/components/Layout.tsx+++ b/dashboard/src/components/Layout.tsx@@ -71,6 +71,9 @@ export function Layout({ onLogout, userRole }: LayoutProps) {const [isCollapsed, setIsCollapsed] = useState(false);const [isMobileOpen, setIsMobileOpen] = useState(false);const [isMobile, setIsMobile] = useState(window.innerWidth < 768);+ // Collapsing is a desktop preference: the phone drawer has no collapse control, so it never renders collapsed,+ // and the flag stays as it was for when the window widens again.+ const collapsed = isCollapsed && !isMobile;// Show the build-time version immediately, then replace it with the live running version from the// backend so a stale-built bundle can't display the wrong number. Falls back silently on error.const [version, setVersion] = useState(__APP_VERSION__);@@ -183,11 +186,11 @@ export function Layout({ onLogout, userRole }: LayoutProps) {{isMobile && isMobileOpen && <div className="sidebar-overlay" onClick={() => setIsMobileOpen(false)} />}<aside- className={`sidebar ${isCollapsed ? 'collapsed' : ''} ${isMobile ? 'mobile' : ''} ${isMobileOpen ? 'open' : ''}`}+ className={`sidebar ${collapsed ? 'collapsed' : ''} ${isMobile ? 'mobile' : ''} ${isMobileOpen ? 'open' : ''}`}><div className="sidebar-header"><img src="/openwa_logo.webp" alt="OpenWA" className="sidebar-logo" />- {!isCollapsed && (+ {!collapsed && (<div className="sidebar-brand"><span className="brand-name">{t('common.appName')}</span><span className="brand-version">v{version}</span>@@ -231,10 +234,10 @@ export function Layout({ onLogout, userRole }: LayoutProps) {className={({ isActive }) => `nav-item ${isActive ? 'active' : ''}`}end={to === '/'}onClick={handleNavClick}- title={isCollapsed ? label : undefined}+ title={collapsed ? label : undefined}><Icon size={20} />- {!isCollapsed && <span>{label}</span>}+ {!collapsed && <span>{label}</span>}</NavLink>);})}@@ -251,7 +254,7 @@ export function Layout({ onLogout, userRole }: LayoutProps) {aria-expanded={isLanguageMenuOpen}><Languages size={18} />- {!isCollapsed && <span>{languageLabel}</span>}+ {!collapsed && <span>{languageLabel}</span>}</button>{isLanguageMenuOpen && (<div className="language-menu-list" role="menu" aria-label={t('common.language')}>@@ -279,17 +282,17 @@ export function Layout({ onLogout, userRole }: LayoutProps) {<span className="appearance-button-cue" aria-hidden="true"><ThemeIcon size={16} /></span>- {!isCollapsed && <span>{themeLabel}</span>}+ {!collapsed && <span>{themeLabel}</span>}</button></div>- <button className="logout-btn" onClick={onLogout} title={isCollapsed ? t('common.logout') : undefined}>+ <button className="logout-btn" onClick={onLogout} title={collapsed ? t('common.logout') : undefined}><LogOut size={20} />- {!isCollapsed && <span>{t('common.logout')}</span>}+ {!collapsed && <span>{t('common.logout')}</span>}</button></div></aside>- <main className={`main-content ${isCollapsed ? 'expanded' : ''} ${isMobile ? 'mobile' : ''}`}>+ <main className={`main-content ${collapsed ? 'expanded' : ''} ${isMobile ? 'mobile' : ''}`}><Outlet /></main></div>