Skip to content

Commit 2a0d720

Browse files
committed
Rollup merge of rust-lang#53405 - oconnor663:search_esc, r=GuillaumeGomez
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?
2 parents b21e956 + 2075509 commit 2a0d720

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/librustdoc/html/static/main.js

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
var themesWidth = null;
5454

55+
var titleBeforeSearch = document.title;
56+
5557
if (!String.prototype.startsWith) {
5658
String.prototype.startsWith = function(searchString, position) {
5759
position = position || 0;
@@ -267,6 +269,7 @@
267269
ev.preventDefault();
268270
addClass(search, "hidden");
269271
removeClass(document.getElementById("main"), "hidden");
272+
document.title = titleBeforeSearch;
270273
}
271274
defocusSearchBar();
272275
}

0 commit comments

Comments
 (0)