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); } });