diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-02-23 02:51:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-23 02:51:54 +0100 |
| commit | 8541435e8d238c93cd9c72dae406f4135c162d25 (patch) | |
| tree | 8fae6be31930a319f1f24c0cf2f933551fe19def | |
| parent | 8979fd42379628201896a5c0dd478c0a5dbd3405 (diff) | |
| parent | eeb555266764069937491a26e817d4bcfea5da3a (diff) | |
| download | rust-8541435e8d238c93cd9c72dae406f4135c162d25.tar.gz rust-8541435e8d238c93cd9c72dae406f4135c162d25.zip | |
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```
| -rw-r--r-- | src/librustdoc/html/static/main.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index d6d3171afbf..6da3b54289b 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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 |
