Skip to content

Commit

Permalink
Rollup merge of rust-lang#72272 - GuillaumeGomez:fix-back-on-page-wit…
Browse files Browse the repository at this point in the history
…h-search-behaviour, r=kinnison

Fix going back in history to a search result page on firefox

This bug was actually firefox not re-running JS script when you go back in history. To trigger it on the current docs:

 * Make a search
 * Pick an element (which isn't on the same page as the current element!)
 * Go back in history

Instead of having the search results, you'll see the normal doc page. You can find a small explanation about it [here](http://web.archive.org/web/20100428053932/http://www.firefoxanswer.com/firefox/672-firefoxanswer.html).

r? @kinnison

cc @ollie27
  • Loading branch information
Dylan-DPC authored May 20, 2020
2 parents a8f9c34 + ed84780 commit daed2a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2787,3 +2787,9 @@ function focusSearchBar() {
function defocusSearchBar() {
getSearchInput().blur();
}

// This is required in firefox. Explanations: when going back in the history, firefox doesn't re-run
// the JS, therefore preventing rustdoc from setting a few things required to be able to reload the
// previous search results (if you navigated to a search result with the keyboard, pressed enter on
// it to navigate to that result, and then came back to this page).
window.onunload = function(){};

0 comments on commit daed2a2

Please sign in to comment.