forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#98775 - notriddle:notriddle/mobile-sidebar-…
…scroll-lock, r=jsha rustdoc: improve scroll locking in the rustdoc mobile sidebars This PR prevents the main content area from scrolling while the mobile sidebar is open on documentation pages (porting the scroll locking behavior from the source sidebar to the regular sidebar), and also fixes some bad behavior where opening a "mobile" sidebar, and growing the viewport so that the "desktop" mode without scroll locking is activated, could potentially leave the page stuck. This does not affect the behavior on larger screens. Only small ones, where the sidebar covers up the main content. Split out from rust-lang#98772
- Loading branch information
Showing
4 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// This test ensures that the mobile sidebar preserves scroll position. | ||
goto: file://|DOC_PATH|/test_docs/struct.Foo.html | ||
// Switching to "mobile view" by reducing the width to 600px. | ||
size: (600, 600) | ||
assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) | ||
|
||
// Scroll down. | ||
scroll-to: "//h2[@id='blanket-implementations']" | ||
assert-window-property: {"pageYOffset": "702"} | ||
|
||
// Open the sidebar menu. | ||
click: ".sidebar-menu-toggle" | ||
wait-for-css: (".sidebar", {"left": "0px"}) | ||
|
||
// We are no longer "scrolled". It's important that the user can't | ||
// scroll the body at all, but these test scripts are run only in Chrome, | ||
// and we need to use a more complicated solution to this problem because | ||
// of Mobile Safari... | ||
assert-window-property: {"pageYOffset": "0"} | ||
|
||
// Close the sidebar menu. Make sure the scroll position gets restored. | ||
click: ".sidebar-menu-toggle" | ||
wait-for-css: (".sidebar", {"left": "-1000px"}) | ||
assert-window-property: {"pageYOffset": "702"} | ||
|
||
// Now test that scrollability returns when the browser window is just resized. | ||
click: ".sidebar-menu-toggle" | ||
wait-for-css: (".sidebar", {"left": "0px"}) | ||
assert-window-property: {"pageYOffset": "0"} | ||
size: (900, 900) | ||
assert-window-property: {"pageYOffset": "702"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters