Skip to content

Commit

Permalink
Remove query parameters when leaving search results
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 17, 2021
1 parent 323fb71 commit eeb5552
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eeb5552

Please sign in to comment.