Skip to content

Commit b19f37c

Browse files
Rollup merge of #87167 - GuillaumeGomez:sidebar-display-mobile, r=notriddle
Fix sidebar display on small devices Part of #87059. Instead of hiding the sidebar on small devices, we instead move it out of the viewport so that it remains "visible" to our text only users. Could you confirm it works for you `@ahicks92` and `@DataTriny` please? You can give it a try at [this URL](https://guillaume-gomez.fr/rustdoc-test/test_docs/index.html). r? `@notriddle`
2 parents a547abe + 868ffd0 commit b19f37c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/librustdoc/html/static/css/rustdoc.css

+6-4
Original file line numberDiff line numberDiff line change
@@ -1634,15 +1634,18 @@ details.undocumented[open] > summary::before {
16341634
display: none;
16351635
}
16361636

1637+
/* We do NOT hide this element so that alternative device readers still have this information
1638+
available. */
16371639
.sidebar-elems {
16381640
position: fixed;
16391641
z-index: 1;
1640-
left: 0;
16411642
top: 45px;
16421643
bottom: 0;
1644+
width: 246px;
1645+
/* We move the sidebar to the left by its own width so it doesn't appear. */
1646+
left: -246px;
16431647
overflow-y: auto;
16441648
border-right: 1px solid;
1645-
display: none;
16461649
}
16471650

16481651
.sidebar > .block.version {
@@ -1730,8 +1733,7 @@ details.undocumented[open] > summary::before {
17301733
}
17311734

17321735
.show-it {
1733-
display: block;
1734-
width: 246px;
1736+
left: 0;
17351737
}
17361738

17371739
.show-it > .block.items {
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport.
2+
// This is especially important for devices for "text-first" content (like for users with
3+
// sight issues).
4+
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
5+
// Switching to "mobile view" by reducing the width to 600px.
6+
size: (600, 600)
7+
assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})
8+
// Opening the sidebar menu.
9+
click: ".sidebar-menu"
10+
assert-css: (".sidebar-elems", {"display": "block", "left": "0px"})

0 commit comments

Comments
 (0)