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