Skip to content

Commit 8541435

Browse files
authored
Rollup merge of #82234 - GuillaumeGomez:remove-query-param-on-esc, r=Nemo157
Remove query parameters when skipping search results Fixes #81330. This PR changes the following: when pressing ESC and that no other "action" was performed (understand: no closing the search result, or hiding a menu or something along the line), then we discard the URL query parameters (the `?whatever=dsjfs`). What do you think about this change ```@rust-lang/rustdoc``` ? EDIT: finally we're simply removing the query parameter when we're skipping the search results. r? ```@Nemo157```
2 parents 8979fd4 + eeb5552 commit 8541435

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustdoc/html/static/main.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function focusSearchBar() {
101101
getSearchInput().focus();
102102
}
103103

104-
// Removes the focus from the search bar
104+
// Removes the focus from the search bar.
105105
function defocusSearchBar() {
106106
getSearchInput().blur();
107107
}
@@ -220,6 +220,11 @@ function defocusSearchBar() {
220220
addClass(search, "hidden");
221221
removeClass(main, "hidden");
222222
document.title = titleBeforeSearch;
223+
// We also remove the query parameter from the URL.
224+
if (browserSupportsHistoryApi()) {
225+
history.replaceState("", window.currentCrate + " - Rust",
226+
getNakedUrl() + window.location.hash);
227+
}
223228
}
224229

225230
// used for special search precedence

0 commit comments

Comments
 (0)