0f6753e2c7738d05fbdd3779329f6ec65542a08b
chmalee
  Tue Nov 21 12:42:57 2023 -0800
Fix show more link text to update correct after showing and then hiding results. Fix show more link to be an href-less anchor so the web browser doesn't jump to the top during a click, refs #31501

diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js
index 5e4a301..723bf6d 100644
--- src/hg/js/hgSearch.js
+++ src/hg/js/hgSearch.js
@@ -549,30 +549,31 @@
                 this.nextSibling.innerHTML = newText;
                 this.src = "../images/remove_sm.gif";
             } else {
                 // click on the link text
                 this.innerHTML = this.innerHTML.replace(/Show/,"Hide");
                 let img = document.getElementById(btnId);
                 img.src = "../images/remove_sm.gif";
             }
         } else {
             if (this.nextSibling) {
                 // click on the '-' icon
                 newText = this.nextSibling.innerHTML.replace(/Hide/,"Show");
                 this.nextSibling.innerHTML = newText;
                 this.src = "../images/add_sm.gif";
             } else {
+                this.innerHTML = this.innerHTML.replace(/Hide/,"Show");
                 let img = document.getElementById(btnId);
                 img.src = "../images/add_sm.gif";
             }
         }
     }
 
     function collapseNode() {
         var toCollapse = this.parentNode.childNodes[3];
         var isHidden  = toCollapse.style.display === "none";
         if (isHidden)
             {
             toCollapse.style = 'display:';
             this.src = "../images/remove_sm.gif";
             }
         else
@@ -618,37 +619,37 @@
                 newListObj.setAttributeNode(noLiStyle);
                 newListObj.innerHTML += "<input type='hidden' id='" + idAttr.value + categoryCount + "' value='0'>";
                 newListObj.innerHTML += "<img height='18' width='18' id='" + idAttr.value + categoryCount + "_button' src='../images/remove_sm.gif'>";
                 newListObj.innerHTML += "&nbsp;" + searchDesc + ":";
                 //printOneFullMatch(newList, matches[0], title, searchDesc);
                 // Now loop through each actual hit on this table and unpack onto list
                 var subList = document.createElement("ul");
                 printMatches(subList, matches, title, searchDesc);
                 if (matches.length > 10) {
                     idStr = idAttr.value + "_" + categoryCount;
                     subList.innerHTML += "<li class='liNoStyle'>";
                     subList.innerHTML += "<input type='hidden' id='" + idStr +  "showMore' value='0'>";
                     subList.innerHTML += "<img height='18' width='18' id='" + idStr + "_showMoreButton' src='../images/add_sm.gif'>";
                     if (matches.length > 500) {
                         let newText  = "<div class='showMoreDiv' id='" + idStr +"_showMoreDiv'>";
-                        newText += "&nbsp;<a href='#' id='"+ idStr + "_showMoreLink'>";
+                        newText += "&nbsp;<a id='"+ idStr + "_showMoreLink'>";
                         newText += "Show 490 (out of " + (matches.length) + " total) more matches for " + searchDesc;
                         newText += "</a></div></li>";
                         subList.innerHTML += newText;
                     } else {
                         let newText = "<div class='showMoreDiv' id='" + idStr + "_showMoreDiv'>";
-                        newText += "&nbsp;<a href='#' id='"+ idStr + "_showMoreLink'>";
+                        newText += "&nbsp;<a id='"+ idStr + "_showMoreLink'>";
                         newText += "Show " + (matches.length - 10) + " more matches for " + searchDesc;
                         newText += "</a></div></li>";
                         subList.innerHTML += newText;
                     }
                 }
                 newListObj.append(subList);
                 newList.append(newListObj);
 
                 // make result list collapsible:
                 $('#'+idAttr.value+categoryCount+"_button").click(collapseNode);
                 $('#'+idAttr.value+"_" +categoryCount+"_showMoreButton").click(showMoreResults);
                 $('#'+idAttr.value + "_" + categoryCount + "_showMoreLink").click(showMoreResults);
                 categoryCount += 1;
             });
         } else if (uiState && typeof uiState.search !== "undefined") {