From 424f3f9f95cda4e9299816f0e58cb77241810e39 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 6 Apr 2026 23:22:45 -0400 Subject: [PATCH] Fix sidebar toggle button by binding directly instead of delegating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Event delegation for toggle-sidebar was inside the isDashboard guard so it could silently not register. Bind .lt-sidebar-toggle buttons directly on DOMContentLoaded — simple and guaranteed to work. Co-Authored-By: Claude Sonnet 4.6 --- assets/js/dashboard.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/assets/js/dashboard.js b/assets/js/dashboard.js index dd94b9e..e48ddb2 100644 --- a/assets/js/dashboard.js +++ b/assets/js/dashboard.js @@ -76,7 +76,7 @@ function initMobileSidebar() { } -// Restore sidebar state on page load +// Restore sidebar state and bind toggle button directly (no event delegation) document.addEventListener('DOMContentLoaded', function() { const savedState = localStorage.getItem('sidebarCollapsed'); const sidebar = document.getElementById('lt-sidebar'); @@ -89,6 +89,15 @@ document.addEventListener('DOMContentLoaded', function() { btn.setAttribute('aria-expanded', 'false'); } } + + // Bind directly — bypass event delegation entirely so it works + // regardless of isDashboard guard or overflow/clipping issues + document.querySelectorAll('.lt-sidebar-toggle').forEach(function(btn) { + btn.addEventListener('click', function(e) { + e.stopPropagation(); + toggleSidebar(); + }); + }); }); // Main initialization @@ -226,10 +235,6 @@ document.addEventListener('DOMContentLoaded', function() { case 'open-advanced-search': if (typeof openAdvancedSearch === 'function') openAdvancedSearch(); break; - // Sidebar toggle - case 'toggle-sidebar': - toggleSidebar(); - break; // Mobile navigation case 'open-mobile-sidebar': if (typeof openMobileSidebar === 'function') openMobileSidebar();