Skip to content

Commit

Permalink
Rollup merge of rust-lang#82234 - GuillaumeGomez:remove-query-param-o…
Browse files Browse the repository at this point in the history
…n-esc, r=Nemo157

Remove query parameters when skipping search results

Fixes rust-lang#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`
  • Loading branch information
GuillaumeGomez authored Feb 22, 2021
2 parents 89e2f77 + eeb5552 commit 399431c
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 399431c

Please sign in to comment.