Skip to content

Commit

Permalink
Rollup merge of #87180 - notriddle:notriddle/sidebar-keyboard-mobile,…
Browse files Browse the repository at this point in the history
… r=GuillaumeGomez

feat(rustdoc): open sidebar menu when links inside it are focused

Fixes #87172

Based on #87167 (which should be merged first)

r? ``@GuillaumeGomez``

Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html
  • Loading branch information
GuillaumeGomez authored Jul 16, 2021
2 parents 4fbac29 + 0ea2980 commit 12ed22f
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 @@ -1732,7 +1732,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 12ed22f

Please sign in to comment.