Fix sidebar toggle button by binding directly instead of delegating
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 <noreply@anthropic.com>
This commit is contained in:
+10
-5
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user