Fix sidebar arrow direction: use CSS rotation not JS icon swap
The CSS already handles the arrow direction with transform:rotate(180deg) on .app-sidebar.collapsed .sidebar-collapse-btn. The JS icon className swap was fighting with CSS rotation causing a double-flip. Remove JS icon manipulation, let CSS handle it. Also suppress the button transition on page load. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
+2
-4
@@ -11,22 +11,20 @@
|
||||
function applyCollapsed(collapsed) {
|
||||
sidebar.classList.toggle('collapsed', collapsed);
|
||||
contentWrapper.classList.toggle('sidebar-collapsed', collapsed);
|
||||
const icon = toggleBtn && toggleBtn.querySelector('i');
|
||||
if (icon) {
|
||||
icon.className = collapsed ? 'fas fa-chevron-right' : 'fas fa-chevron-left';
|
||||
}
|
||||
}
|
||||
|
||||
// Restore saved state instantly — suppress transitions so there's no
|
||||
// collapse animation flash on every page navigation.
|
||||
sidebar.style.transition = 'none';
|
||||
contentWrapper.style.transition = 'none';
|
||||
if (toggleBtn) toggleBtn.style.transition = 'none';
|
||||
applyCollapsed(localStorage.getItem(COLLAPSED_KEY) === '1');
|
||||
// Re-enable transitions after one frame so the toggle button still animates.
|
||||
requestAnimationFrame(function () {
|
||||
requestAnimationFrame(function () {
|
||||
sidebar.style.transition = '';
|
||||
contentWrapper.style.transition = '';
|
||||
if (toggleBtn) toggleBtn.style.transition = '';
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user