Skip to content

Commit d4e4b08

Browse files
committed
rustdoc: change mobile breakpoint to match CSS
Since it's possible to have a 700.5px viewport width, the JS needs to not switch to mobile mode in such a setup.
1 parent bbac29c commit d4e4b08

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/librustdoc/html/static/js/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ function loadCss(cssFileName) {
737737

738738
window.rustdocMobileScrollLock = function() {
739739
const mobile_topbar = document.querySelector(".mobile-topbar");
740-
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
740+
if (window.innerWidth <= window.RUSTDOC_MOBILE_BREAKPOINT) {
741741
// This is to keep the scroll position on mobile.
742742
oldSidebarScrollPosition = window.scrollY;
743743
document.body.style.width = `${document.body.offsetWidth}px`;
@@ -783,7 +783,7 @@ function loadCss(cssFileName) {
783783
}
784784

785785
window.addEventListener("resize", () => {
786-
if (window.innerWidth >= window.RUSTDOC_MOBILE_BREAKPOINT &&
786+
if (window.innerWidth > window.RUSTDOC_MOBILE_BREAKPOINT &&
787787
oldSidebarScrollPosition !== null) {
788788
// If the user opens the sidebar in "mobile" mode, and then grows the browser window,
789789
// we need to switch away from mobile mode and make the main content area scrollable.

src/librustdoc/html/static/js/storage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ window.mainTheme = document.getElementById("mainThemeStyle");
1212
// WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY
1313
// If you update this line, then you also need to update the media query with the same
1414
// warning in rustdoc.css
15-
window.RUSTDOC_MOBILE_BREAKPOINT = 701;
15+
window.RUSTDOC_MOBILE_BREAKPOINT = 700;
1616

1717
const settingsDataset = (function() {
1818
const settingsElement = document.getElementById("default-settings");

src/test/rustdoc-gui/sidebar-mobile-scroll.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// This test ensures that the mobile sidebar preserves scroll position.
22
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
33
// Switching to "mobile view" by reducing the width to 600px.
4-
size: (600, 600)
4+
size: (700, 600)
55
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
66

77
// Scroll down.
88
scroll-to: "//h2[@id='blanket-implementations']"
9-
assert-window-property: {"pageYOffset": "651"}
9+
assert-window-property: {"pageYOffset": "627"}
1010

1111
// Open the sidebar menu.
1212
click: ".sidebar-menu-toggle"
@@ -21,11 +21,11 @@ assert-window-property: {"pageYOffset": "0"}
2121
// Close the sidebar menu. Make sure the scroll position gets restored.
2222
click: ".sidebar-menu-toggle"
2323
wait-for-css: (".sidebar", {"left": "-1000px"})
24-
assert-window-property: {"pageYOffset": "651"}
24+
assert-window-property: {"pageYOffset": "627"}
2525

2626
// Now test that scrollability returns when the browser window is just resized.
2727
click: ".sidebar-menu-toggle"
2828
wait-for-css: (".sidebar", {"left": "0px"})
2929
assert-window-property: {"pageYOffset": "0"}
3030
size: (900, 600)
31-
assert-window-property: {"pageYOffset": "651"}
31+
assert-window-property: {"pageYOffset": "627"}

0 commit comments

Comments
 (0)