]> git.lizzy.rs Git - rust.git/commitdiff
Remove query parameters when leaving search results
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 17 Feb 2021 19:24:50 +0000 (20:24 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 17 Feb 2021 21:04:30 +0000 (22:04 +0100)
src/librustdoc/html/static/main.js

index ec89ae0228c5e412ecb021371f5d4593710ea73a..e8daa8414a2743bc0246dbc5c78b8bc569a576cd 100644 (file)
@@ -101,7 +101,7 @@ function focusSearchBar() {
     getSearchInput().focus();
 }
 
-// Removes the focus from the search bar
+// Removes the focus from the search bar.
 function defocusSearchBar() {
     getSearchInput().blur();
 }
@@ -220,6 +220,11 @@ function defocusSearchBar() {
         addClass(search, "hidden");
         removeClass(main, "hidden");
         document.title = titleBeforeSearch;
+        // We also remove the query parameter from the URL.
+        if (browserSupportsHistoryApi()) {
+            history.replaceState("", window.currentCrate + " - Rust",
+                getNakedUrl() + window.location.hash);
+        }
     }
 
     // used for special search precedence