From 3c3c8bba710d84bb8434e0903fb757b1e00968f8 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Mon, 10 Aug 2026 05:00:22 -0400 Subject: [PATCH] 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 <223556219+Copilot@users.noreply.github.com> --- static/js/theme.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/js/theme.js b/static/js/theme.js index a35d786..39af3aa 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -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 () {