Skip to content

Commit

Permalink
rustdoc: fix up sidebar width on browser back
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Sep 8, 2023
1 parent e496f50 commit cc5a9ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -209,7 +209,8 @@ if (getSettingValue("hide-sidebar") === "true") {
srcSidebarWidth + "px"
);
}
}());
};
updateSidebarWidth();

// 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.
Expand All @@ -223,5 +224,6 @@ if (getSettingValue("hide-sidebar") === "true") {
window.addEventListener("pageshow", ev => {
if (ev.persisted) {
setTimeout(updateTheme, 0);
setTimeout(updateSidebarWidth, 0);
}
});

0 comments on commit cc5a9ca

Please sign in to comment.