Skip to content

Commit 12ed22f

Browse files
Rollup merge of rust-lang#87180 - notriddle:notriddle/sidebar-keyboard-mobile, r=GuillaumeGomez
feat(rustdoc): open sidebar menu when links inside it are focused Fixes rust-lang#87172 Based on rust-lang#87167 (which should be merged first) r? ``@GuillaumeGomez`` Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html
2 parents 4fbac29 + 0ea2980 commit 12ed22f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,8 @@ details.undocumented[open] > summary::before {
17321732
width: calc(100% + 30px);
17331733
}
17341734

1735-
.show-it {
1735+
.show-it, .sidebar-elems:focus-within {
1736+
z-index: 2;
17361737
left: 0;
17371738
}
17381739

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

+10
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})
88
// Opening the sidebar menu.
99
click: ".sidebar-menu"
1010
assert-css: (".sidebar-elems", {"display": "block", "left": "0px"})
11+
// Closing the sidebar menu.
12+
click: ".sidebar-menu"
13+
assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})
14+
// Force the sidebar open by focusing a link inside it.
15+
// This makes it easier for keyboard users to get to it.
16+
focus: ".sidebar-title"
17+
assert-css: (".sidebar-elems", {"display": "block", "left": "0px"})
18+
// When we tab out of the sidebar, close it.
19+
focus: ".search-input"
20+
assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})

0 commit comments

Comments
 (0)