From 96836e75d3552884555c89b382c219f43818b556 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 7 Sep 2023 21:43:32 -0700 Subject: [PATCH] rustdoc: fix up sidebar width on browser back --- src/librustdoc/html/static/js/storage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 7092581cb6cf..46ba5ca889c0 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -194,7 +194,7 @@ if (getSettingValue("hide-sidebar") === "true") { addClass(document.documentElement, "hide-sidebar"); } -(function() { +function updateSidebarWidth() { const desktopSidebarWidth = getSettingValue("desktop-sidebar-width"); if (desktopSidebarWidth) { document.documentElement.style.setProperty( @@ -209,7 +209,7 @@ if (getSettingValue("hide-sidebar") === "true") { srcSidebarWidth + "px" ); } -}()); +}; // If we navigate away (for example to a settings page), and then use the back or // forward button to get back to a page, the theme may have changed in the meantime. @@ -223,5 +223,6 @@ if (getSettingValue("hide-sidebar") === "true") { window.addEventListener("pageshow", ev => { if (ev.persisted) { setTimeout(updateTheme, 0); + setTimeout(updateSidebarWidth, 0); } });