16eee40c920d259c10ee345472708d0cc0cc3393 chmalee Tue Mar 3 11:25:23 2026 -0800 Adds an hg.conf defined 'popular' species list to the new search bar as a 'default' list of results upon focus of the search bar. Combines with 'recents' list. Add a chevron next to the search bar so users know the autocomplete has some default options, refs #36232 diff --git src/hg/js/autocompleteCat.js src/hg/js/autocompleteCat.js index 748733ba6ed..61a4fc722ac 100644 --- src/hg/js/autocompleteCat.js +++ src/hg/js/autocompleteCat.js @@ -127,42 +127,45 @@ let results = options.onError(jqXHR, textStatus, errorThrown, cleanedTerm); if (results) { acCallback(results); } } }); }; var autoCompleteSource = function(request, acCallback) { // This is a callback for jqueryui.autocomplete: when the user types // a character, this is called with the input value as request.term and an acCallback // for this to return the result to autocomplete. // See http://api.jqueryui.com/autocomplete/#option-source // Note: 'this' is the widget instance - // Handle recent genomes for species search bars + // Handle recent + popular genomes for species search bars if (options.showRecentGenomes && request.term.length < 2) { let recent = getRecentGenomes(); + let popular = getPopularGenomes($el); if (request.term.length === 0) { - // On focus with empty input, show all recent genomes - if (recent.length > 0) { - acCallback(recent); + // On focus with empty input, show recent + popular genomes + let combined = recent.concat(popular); + if (combined.length > 0) { + acCallback(combined); return; } } else { - // On typing 1 char, filter recent genomes - let matching = recent.filter(item => + // On typing 1 char, filter recent + popular genomes + let all = recent.concat(popular); + let matching = all.filter(item => item.label.toLowerCase().includes(request.term.toLowerCase()) || item.genome.toLowerCase().includes(request.term.toLowerCase()) ); if (matching.length > 0) { acCallback(matching); return; } } } // Handle recent searches for position input if (this.element[0].id === "positionInput" && request.term.length < 2) { let searchStack = window.localStorage.getItem("searchStack"); if (request.term.length === 0 && searchStack) { let searchObj = JSON.parse(searchStack);