Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,9 @@ function hideThemeButtonState() {
handleClick("help-button", function(ev) {
displayHelp(true, ev);
});
handleClick(MAIN_ID, function() {
hideSidebar();
});

onEachLazy(document.getElementsByTagName("a"), function(el) {
// For clicks on internal links (<A> tags with a hash property), we expand the section we're
Expand All @@ -905,6 +908,7 @@ function hideThemeButtonState() {
if (el.hash) {
el.addEventListener("click", function() {
expandSection(el.hash.slice(1));
hideSidebar();
});
}
});
Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ 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"})

// Open the sidebar menu.
click: ".sidebar-menu"
assert-css: (".sidebar-elems", {"left": "0px"})

// Click elsewhere.
click: "body"
assert-css: (".sidebar-elems", {"left": "-246px"})