diff --git a/frontend/app.js b/frontend/app.js index 9de4d7e..b934e9b 100755 --- a/frontend/app.js +++ b/frontend/app.js @@ -1741,6 +1741,8 @@ function render() { listFilter = ''; const fi = $('listFilterInput'); if (fi) fi.value = ''; + // On mobile, navigating (nav item / playlist / search) dismisses the drawer. + if (typeof closeSidebar === 'function') closeSidebar(); exitSelectMode(); renderSidebar(); renderSmartSidebar(); @@ -1977,7 +1979,38 @@ function closeModal() { $('modal').classList.add('hidden'); } // ============================================================================ // Events // ============================================================================ +// ============================================================================ +// Responsive sidebar drawer (mobile) +// ============================================================================ +function openSidebar() { + const app = document.querySelector('.app'); + if (!app) return; + app.classList.add('sidebar-open'); + const t = $('sidebarToggle'); + if (t) t.setAttribute('aria-expanded', 'true'); +} +function closeSidebar() { + const app = document.querySelector('.app'); + if (!app) return; + app.classList.remove('sidebar-open'); + const t = $('sidebarToggle'); + if (t) t.setAttribute('aria-expanded', 'false'); +} +function setupSidebarDrawer() { + const toggle = $('sidebarToggle'); + const backdrop = $('sidebarBackdrop'); + if (toggle) { + toggle.addEventListener('click', () => { + const app = document.querySelector('.app'); + if (app && app.classList.contains('sidebar-open')) closeSidebar(); + else openSidebar(); + }); + } + if (backdrop) backdrop.addEventListener('click', closeSidebar); +} + function wireUI() { + setupSidebarDrawer(); els.searchForm.addEventListener('submit', async (e) => { e.preventDefault(); const q = els.searchInput.value.trim(); @@ -2233,7 +2266,9 @@ document.querySelectorAll('.chip').forEach((c) => { else if (e.key === 'b') { if (current) setAbB(); } else if (e.key === '?') toggleShortcutHelp(); else if (e.key === 'Escape') { - if (!$('shortcutHelp').classList.contains('hidden')) $('shortcutHelp').classList.add('hidden'); + const app = document.querySelector('.app'); + if (app && app.classList.contains('sidebar-open')) closeSidebar(); + else if (!$('shortcutHelp').classList.contains('hidden')) $('shortcutHelp').classList.add('hidden'); else if (selectMode) { exitSelectMode(); renderList(); } } }); diff --git a/frontend/index.html b/frontend/index.html index b0c79f5..856666f 100755 --- a/frontend/index.html +++ b/frontend/index.html @@ -25,7 +25,7 @@