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 <guillaume.gomez@huawei.com>
This commit is contained in:
Michael Howell 2021-07-16 08:04:49 -07:00
parent 868ffd03ed
commit 0ea2980ae5
2 changed files with 12 additions and 1 deletions

View File

@ -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;
}

View File

@ -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"})