da2089fb286b3119d62399a747a23fc22fa3ad70
chmalee
  Wed Mar 18 16:53:36 2026 -0700
Add plain position searches to the recents search stack on hgTracks/hgGateway, refs #34588

diff --git src/hg/js/autocomplete.js src/hg/js/autocomplete.js
index f5da6076455..229fba1bc82 100644
--- src/hg/js/autocomplete.js
+++ src/hg/js/autocomplete.js
@@ -16,31 +16,34 @@
         var cache = {}; // cache is is used as a hash to cache responses from the server.
         return function(request, callback) {
             var key = request.term;
             if (key.length < 2) {
                 // show the most recent searches
                 let searchStack = window.localStorage.getItem("searchStack");
                 if (key.length === 0 && searchStack) {
                     let searchObj = JSON.parse(searchStack);
                     let currDb = getDb();
                     if (currDb in searchObj) {
                         // sort the results list according to the stack order:
                         let entries = Object.entries(searchObj[currDb].results);
                         let stack = searchObj[currDb].stack;
                         let callbackData = [];
                         for (let s of stack) {
-                            callbackData.push(searchObj[currDb].results[s]);
+                            let item = searchObj[currDb].results[s];
+                            if (item && item.label) {
+                                callbackData.push(item);
+                            }
                         }
                         callback(callbackData);
                     }
                     return;
                 } else {
                     return;
                 }
             }
             if (!cache[key]) {
                 if (key.length < 8) {
                     // probably a gene name
                     $.ajax({
                         url: "../cgi-bin/hgSuggest",
                         data: "db=" + db + "&prefix=" + encodeURIComponent(key),
                         // dataType: "json",  // XXXX this doesn't work under IE, so we retrieve as text and do an eval to force to an object.