File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
src/librustdoc/html/static Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -2000,6 +2000,20 @@ function defocusSearchBar() {
20002000 } ) ;
20012001 }
20022002 search ( ) ;
2003+
2004+ // This is required in firefox to avoid this problem: Navigating to a search result
2005+ // with the keyboard, hitting enter, and then hitting back would take you back to
2006+ // the doc page, rather than the search that should overlay it.
2007+ // This was an interaction between the back-forward cache and our handlers
2008+ // that try to sync state between the URL and the search input. To work around it,
2009+ // do a small amount of re-init on page show.
2010+ window . onpageshow = function ( ) {
2011+ var qSearch = getQueryStringParams ( ) . search ;
2012+ if ( search_input . value === "" && qSearch ) {
2013+ search_input . value = qSearch ;
2014+ }
2015+ search ( ) ;
2016+ } ;
20032017 }
20042018
20052019 index = buildIndex ( rawSearchIndex ) ;
@@ -2958,9 +2972,3 @@ function defocusSearchBar() {
29582972 onHashChange ( null ) ;
29592973 window . onhashchange = onHashChange ;
29602974} ( ) ) ;
2961-
2962- // This is required in firefox. Explanations: when going back in the history, firefox doesn't re-run
2963- // the JS, therefore preventing rustdoc from setting a few things required to be able to reload the
2964- // previous search results (if you navigated to a search result with the keyboard, pressed enter on
2965- // it to navigate to that result, and then came back to this page).
2966- window . onunload = function ( ) { } ;
You can’t perform that action at this time.
0 commit comments