Remove query parameters when leaving search results

This commit is contained in:
Guillaume Gomez 2021-02-17 20:24:50 +01:00
parent 323fb7113b
commit eeb5552667

View 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