Skip to content

Commit 0ea2980

Browse files
feat(rustdoc): open sidebar menu when links inside it are focused
Fixes #87172 Based on #87167 (which should be merged first) Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html Co-authored-by: Guillaume Gomez <[email protected]>
1 parent 868ffd0 commit 0ea2980

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: src/librustdoc/html/static/css/rustdoc.css

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

1732-
.show-it {
1732+
.show-it, .sidebar-elems:focus-within {
1733+
z-index: 2;
17331734
left: 0;
17341735
}
17351736

Diff for: 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)