Skip to content

Commit 72338b8

Browse files
Allow to go back to previous search
1 parent acd5e8c commit 72338b8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/librustdoc/html/static/main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
addClass(search, "hidden");
151151
removeClass(document.getElementById("main"), "hidden");
152152
var hash = ev.newURL.slice(ev.newURL.indexOf('#') + 1);
153+
if (browserSupportsHistoryApi()) {
154+
history.replaceState(hash, "", "#" + hash);
155+
}
153156
var elem = document.getElementById(hash);
154157
if (elem) {
155158
elem.scrollIntoView();
@@ -1560,6 +1563,17 @@
15601563
});
15611564
}
15621565
});
1566+
1567+
var search_input = document.getElementsByClassName("search-input")[0];
1568+
1569+
if (search_input) {
1570+
search_input.onfocus = function() {
1571+
if (search.value !== "") {
1572+
addClass(document.getElementById("main"), "hidden");
1573+
removeClass(document.getElementById("search"), "hidden");
1574+
}
1575+
};
1576+
}
15631577
}());
15641578

15651579
// Sets the focus on the search bar at the top of the page

0 commit comments

Comments
 (0)