diff options
| author | bors <bors@rust-lang.org> | 2021-06-23 08:45:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-06-23 08:45:17 +0000 |
| commit | b6f3cb9502b1910f6af32f426fdb78e813b390ef (patch) | |
| tree | 34f10212da90a5ff0c7a33e479ff200da4c08a63 /src/librustdoc | |
| parent | 2ce052bb8d8e4b421f08541ffa1f4c7fc5ea7a72 (diff) | |
| parent | c4023c6ca31f80cb7fa3cbebc9f0095d5f649d53 (diff) | |
Auto merge of #86548 - GuillaumeGomez:fix-crate-filter-search-reset, r=jsha
Fix crate filter search reset I found a fun bug when using rustdoc recently: I made a search, cut the search input content, changed the crate filter, pasted back the input content. To my surprise, the crate filter wasn't applied. It's because that our search input was empty when receiving the `<select>` "onchange" event. To fix this issue, I reset the `currentResults` variable to `null`. It's using the first commit from #86542 so it needs to wait for it before getting merged. r? `@jsha`
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/html/static/search.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/search.js b/src/librustdoc/html/static/search.js index 35be246b5bf..617c79a4579 100644 --- a/src/librustdoc/html/static/search.js +++ b/src/librustdoc/html/static/search.js @@ -1442,6 +1442,10 @@ window.initSearch = function(rawSearchIndex) { if (selectCrate) { selectCrate.onchange = function() { updateLocalStorage("rustdoc-saved-filter-crate", selectCrate.value); + // In case you "cut" the entry from the search input, then change the crate filter + // before paste back the previous search, you get the old search results without + // the filter. To prevent this, we need to remove the previous results. + currentResults = null; search(undefined, true); }; } |
