fb23bce308b7ce29749b4f6a0347bada22e8c885 chmalee Thu Mar 14 15:56:53 2024 -0700 Set the value and label for the autocomplete data to the correct variables so the bolded item stays in the drop down list but then when you select the item the bold tags go away in the input box, refs #29611 diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js index 34f71f1..281ecb0 100644 --- src/hg/js/hgSearch.js +++ src/hg/js/hgSearch.js @@ -850,79 +850,99 @@ // switch lookup depending on the different search categories: let decoder = function(str) { // helper decoder to change the html encoded entities in // uiState.positionMatches.posName to what is actually rendered // in matchStr return $("<textarea/>").html(str).text(); }; let geneSymbol; // a potentially fake geneSymbol for the autoComplete if (trackName === "trackDb") { match = matchList.matches.find((elem) => { let posSplit = elem.posName.split(":"); geneSymbol = decoder(posSplit[1] + " - " + posSplit[2]); id = "hgTrackUi?db=" + uiState.db + "&g=" + posSplit[0]; return geneSymbol === matchStr; }); - callbackData.value = geneSymbol + " " + match.description; + callbackData.label = geneSymbol; + callbackData.value = geneSymbol; + if (typeof match.description !== "undefined") { + callbackData.label += " " + match.description; + // hack to remove the bolding from the item values in the autocomplete + callbackData.value = $("<div>" + match.description + "</div>").text(); + } callbackData.id = id; callbackData.geneSymbol = geneSymbol; callbackData.internalId = ""; } else if (trackName === "publicHubs") { match = matchList.matches.find((elem) => { let posSplit = elem.posName.split(":"); geneSymbol = decoder(posSplit[4] + " - " + trackHubSkipHubName(posSplit[3])); id = "hgTrackUi?hubUrl=" + posSplit[0] + ":" + posSplit[1] + "&g=" + posSplit[3] + "&db=" + posSplit[3]; return decoder(posSplit[4]) === matchStr; }); - callbackData.value = geneSymbol + " " + match.description; + callbackData.label = geneSymbol; + callbackData.value = geneSymbol; + if (typeof match.description !== "undefined") { + callbackData.label += " " + match.description; + // hack to remove the bolding from the item values in the autocomplete + callbackData.value = $("<div>" + match.description + "</div>").text(); + } callbackData.id = id; callbackData.geneSymbol = geneSymbol; callbackData.internalId = ""; } 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.label = geneSymbol; + callbackData.value = geneSymbol; + if (typeof match.description !== "undefined") { + callbackData.label += " " + match.description; + // hack to remove the bolding from the item values in the autocomplete + callbackData.value = $("<div>" + match.description + "</div>").text(); + } 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.label = geneSymbol; callbackData.value = geneSymbol; if (typeof match.description !== "undefined") { - callbackData.value += " " + match.description; + callbackData.label += " " + match.description; + // hack to remove the bolding from the item values in the autocomplete + callbackData.value = $("<div>" + match.description + "</div>").text(); } // 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; addRecentSearch(db, callbackData.geneSymbol, callbackData); window.location = i.href; }); }); } function init() { cart.setCgi('hgSearch'); cart.debug(debugCartJson); // If a user clicks search before the page has finished loading // start processing it now: $("#searchBarSearchButton").click(sendUserSearch); if (typeof cartJson !== "undefined") { if (typeof cartJson.db !== "undefined") { db = cartJson.db;