Skip to content

Commit

Permalink
feat(rustdoc): open sidebar menu when links inside it are focused
Browse files Browse the repository at this point in the history
Fixes rust-lang#87172

Based on rust-lang#87167 (which should be merged first)

Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html

Co-authored-by: Guillaume Gomez <guillaume.gomez@huawei.com>
  • Loading branch information
notriddle and GuillaumeGomez committed Jul 16, 2021
1 parent 868ffd0 commit 0ea2980
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,8 @@ details.undocumented[open] > summary::before {
width: calc(100% + 30px);
}

.show-it {
.show-it, .sidebar-elems:focus-within {
z-index: 2;
left: 0;
}

Expand Down
10 changes: 10 additions & 0 deletions src/test/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})
// Opening the sidebar menu.
click: ".sidebar-menu"
assert-css: (".sidebar-elems", {"display": "block", "left": "0px"})
// Closing the sidebar menu.
click: ".sidebar-menu"
assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})
// Force the sidebar open by focusing a link inside it.
// This makes it easier for keyboard users to get to it.
focus: ".sidebar-title"
assert-css: (".sidebar-elems", {"display": "block", "left": "0px"})
// When we tab out of the sidebar, close it.
focus: ".search-input"
assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})

0 comments on commit 0ea2980

Please sign in to comment.