Skip to content

Commit a72a6ec

Browse files
committed
auto merge of #13830 : noamraph/rust/doc-browser-history, r=kballard
Currently, in both chrome and firefox, if I type something in the search box in the reference docs I get immediately the search results. That's great. However, if I want to go back to the doc I was reading and try to press the back button, I am immediately forwarded again to the search results. This is caused by the fact that the search term is (deliberately) left in the search box, and the search() function is called as if I typed the search term again. I disabled calling the search() function if there's no search term in the URL, and now it seems to work fine. I hope I'm sending the pull request correctly - I'm not really used to git and github.
2 parents 3cd6c1e + 5b2e477 commit a72a6ec

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/librustdoc/html/static/main.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,10 @@
605605
// cleared to ensure the search is successful.
606606
currentResults = null;
607607
// Synchronize search bar with query string state and
608-
// perform the search, but don't empty the bar if there's
609-
// nothing there.
610-
if (params.search !== undefined) {
611-
$('.search-input').val(params.search);
612-
}
608+
// perform the search. This will empty the bar if there's
609+
// nothing there, which lets you really go back to a
610+
// previous state with nothing in the bar.
611+
$('.search-input').val(params.search);
613612
// Some browsers fire 'onpopstate' for every page load
614613
// (Chrome), while others fire the event only when actually
615614
// popping a state (Firefox), which is why search() is

0 commit comments

Comments
 (0)