9302f32f52e5aa823884f7e0b07339b9459fd582
chmalee
  Thu Mar 14 14:26:47 2024 -0700
Only add match description to autocomplete results when it is defined, refs #29611

diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js
index 097e42b..34f71f1 100644
--- src/hg/js/hgSearch.js
+++ src/hg/js/hgSearch.js
@@ -880,31 +880,34 @@
                 } else if (trackName === "helpDocs") {
                     match = matchList.matches.find((elem) => {
                         let posSplit = elem.posName.split(":");
                         geneSymbol = decoder(posSplit[1].replaceAll("_", " "));
                         return geneSymbol === matchStr;
                     });
                     callbackData.value = geneSymbol + " " + match.description;
                     callbackData.id = match.position.split(":")[0];
                     callbackData.geneSymbol = geneSymbol;
                     callbackData.internalId = "";
                 } else { // regular track item  search result click
                     match = matchList.matches.find((elem) => {
                         geneSymbol = elem.posName.replace(/ .*$/,"");
                         return decoder(elem.posName) === matchStr;
                     });
-                    callbackData.value = geneSymbol + " " + match.description;
+                    callbackData.value = geneSymbol;
+                    if (typeof match.description !== "undefined") {
+                        callbackData.value += " " + match.description;
+                    }
                     // special case the genbank searches that are supposed to go to hgc
                     // and not hgTracks
                     let parentTitle = i.parentNode.parentNode.parentNode.childNodes[2];
                     if (["all_mrna", "all_est", "xenoMrna", "xenoEst", "intronEst"].includes(trackName) && parentTitle.textContent.includes("Unaligned")) {
                         id = "hgc?db=" + db + "&g=" + trackName+ "&i=" + match.position + "&c=0&o=0&l=0&r=0" ;
                     } else {
                         id = match.position;
                     }
                     callbackData.id = id;
                     callbackData.geneSymbol = geneSymbol;
                     callbackData.internalId = match.hgFindMatches;
                 }
                 // type for autocomplete select to know where to navigate to
                 callbackData.type = trackName;
                 callbackData.label = callbackData.value;