@@ -2132,8 +2132,8 @@ class DocSearch {
21322132 *
21332133 * @param {rustdoc.ParsedQuery<rustdoc.ParserQueryElement> } parsedQuery
21342134 * - The parsed user query
2135- * @param {Object } filterCrates - Crate to search in if defined
2136- * @param {string } currentCrate - Current crate, to rank results from this crate higher
2135+ * @param {string|null } filterCrates - Crate to search in if defined
2136+ * @param {string|null } currentCrate - Current crate, to rank results from this crate higher
21372137 *
21382138 * @return {Promise<rustdoc.ResultsTable> }
21392139 */
@@ -2765,7 +2765,7 @@ class DocSearch {
27652765 * @this {DocSearch}
27662766 * @param {Array<rustdoc.PlainResultObject|null> } results
27672767 * @param {"sig"|"elems"|"returned"|null } typeInfo
2768- * @param {string } preferredCrate
2768+ * @param {string|null } preferredCrate
27692769 * @param {Set<string> } duplicates
27702770 * @returns {AsyncGenerator<rustdoc.ResultObject, number> }
27712771 */
@@ -3903,7 +3903,7 @@ class DocSearch {
39033903 const innerRunNameQuery =
39043904 /**
39053905 * @this {DocSearch}
3906- * @param {string } currentCrate
3906+ * @param {string|null } currentCrate
39073907 * @returns {AsyncGenerator<rustdoc.ResultObject> }
39083908 */
39093909 async function * ( currentCrate ) {
@@ -4145,7 +4145,7 @@ class DocSearch {
41454145 * @param {rustdoc.ParserQueryElement[] } inputs
41464146 * @param {rustdoc.ParserQueryElement[] } output
41474147 * @param {"sig"|"elems"|"returned"|null } typeInfo
4148- * @param {string } currentCrate
4148+ * @param {string|null } currentCrate
41494149 * @returns {AsyncGenerator<rustdoc.ResultObject> }
41504150 */
41514151 async function * ( inputs , output , typeInfo , currentCrate ) {
@@ -5178,7 +5178,7 @@ function makeTab(tabNb, text, results, query, isTypeSearch, goToFirst) {
51785178 * @param {DocSearch } docSearch
51795179 * @param {rustdoc.ResultsTable } results
51805180 * @param {boolean } goToFirst
5181- * @param {string } filterCrates
5181+ * @param {string|null } filterCrates
51825182 */
51835183async function showResults ( docSearch , results , goToFirst , filterCrates ) {
51845184 const search = window . searchState . outputElement ( ) ;
@@ -5251,6 +5251,8 @@ async function showResults(docSearch, results, goToFirst, filterCrates) {
52515251 }
52525252 const crateSearch = document . getElementById ( "crate-search" ) ;
52535253 if ( crateSearch ) {
5254+ // #crate-search is an input element
5255+ // @ts -expect-error
52545256 crateSearch . addEventListener ( "input" , updateCrate ) ;
52555257 }
52565258 search . appendChild ( tabsElem ) ;
@@ -5328,12 +5330,12 @@ async function search(forced) {
53285330 // recent search query is added to the browser history.
53295331 updateSearchHistory ( buildUrl ( query . userQuery , filterCrates ) ) ;
53305332
5333+ console . log ( filterCrates ) ;
5334+
53315335 await showResults (
53325336 docSearch ,
5333- // @ts -expect-error
53345337 await docSearch . execQuery ( query , filterCrates , window . currentCrate ) ,
53355338 params . go_to_first ,
5336- // @ts -expect-error
53375339 filterCrates ) ;
53385340}
53395341
@@ -5421,16 +5423,17 @@ function registerSearchEvents() {
54215423 }
54225424 e . preventDefault ( ) ;
54235425 } else if ( e . which === 40 ) { // down
5424- // @ts -expect-error
5425- const next = document . activeElement . nextElementSibling ;
5426- if ( next ) {
5427- // @ts -expect-error
5428- next . focus ( ) ;
5429- }
5430- // @ts -expect-error
5431- const rect = document . activeElement . getBoundingClientRect ( ) ;
5432- if ( window . innerHeight - rect . bottom < rect . height ) {
5433- window . scrollBy ( 0 , rect . height ) ;
5426+ const active = document . activeElement ;
5427+ if ( active ) {
5428+ const next = active . nextElementSibling ;
5429+ if ( next ) {
5430+ // @ts -expect-error
5431+ next . focus ( ) ;
5432+ }
5433+ const rect = active . getBoundingClientRect ( ) ;
5434+ if ( window . innerHeight - rect . bottom < rect . height ) {
5435+ window . scrollBy ( 0 , rect . height ) ;
5436+ }
54345437 }
54355438 e . preventDefault ( ) ;
54365439 } else if ( e . which === 37 ) { // left
@@ -5454,7 +5457,9 @@ function registerSearchEvents() {
54545457 } ) ;
54555458}
54565459
5457- // @ts -expect-error
5460+ /**
5461+ * @param {Event & { target: HTMLInputElement } } ev
5462+ */
54585463function updateCrate ( ev ) {
54595464 if ( ev . target . value === "all crates" ) {
54605465 // If we don't remove it from the URL, it'll be picked up again by the search.
0 commit comments