Fix sidebar collapse flash on page navigation

Suppress CSS transitions during initial state restore from localStorage.
Re-enable after two rAF frames so the toggle button still animates smoothly.

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 05:00:22 -04:00
co-authored by Copilot
parent 21e44a8586
commit 3c3c8bba71
+11 -1
View File
@@ -17,8 +17,18 @@
}
}
// Restore saved state
// 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';
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.addEventListener('click', function () {