about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-05-21 13:12:17 +0200
committerGitHub <noreply@github.com>2020-05-21 13:12:17 +0200
commite279bd5366ca4791d9366cfea303ebb427753810 (patch)
tree7e4fd088dbc97657e0e48e2fdbb6b703d2d4e947
parente2c05d1e9cee5f01312ca787ca8afd4179251346 (diff)
parented8478036c416694db5f51f6e43078a1c07532cf (diff)
downloadrust-e279bd5366ca4791d9366cfea303ebb427753810.tar.gz
rust-e279bd5366ca4791d9366cfea303ebb427753810.zip
Rollup merge of #72272 - GuillaumeGomez:fix-back-on-page-with-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
-rw-r--r--src/librustdoc/html/static/main.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 9b498d66249..9869c50fbb0 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -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(){};