Skip to content

Commit

Permalink
Rollup merge of rust-lang#53405 - oconnor663:search_esc, r=GuillaumeG…
Browse files Browse the repository at this point in the history
…omez

restore the page title after escaping out of a search

Currently if I start a search in the docs, but then hit ESC, the "Results for..." title is still there in my browser tab. This is a simple attempt to fix that. I see that there's a separate `var previousTitle = document.title` thing happening in `startSearch()`, but as far as I can tell that's only related to the back stack? I'd also appreciate feedback on the right place to declare the `titleBeforeSearch` variable.

Testing-wise, I've confirmed by hand that the tab title restores correctly after building with `./x.py doc --stage 1 src/libstd`, but nothing more involved than that. What else should I test?
  • Loading branch information
Mark-Simulacrum authored Aug 19, 2018
2 parents a9fe312 + 2075509 commit 1a0efd8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

var themesWidth = null;

var titleBeforeSearch = document.title;

if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
Expand Down Expand Up @@ -267,6 +269,7 @@
ev.preventDefault();
addClass(search, "hidden");
removeClass(document.getElementById("main"), "hidden");
document.title = titleBeforeSearch;
}
defocusSearchBar();
}
Expand Down

0 comments on commit 1a0efd8

Please sign in to comment.