0e7a265a6b8dab3ba98319422893f1121f72e729
chmalee
  Wed Aug 23 15:50:58 2023 -0700
When there is a search warning but we still can get one result, keep the user on hgSearch instead of redirecting to hgTracks, refs #31965

diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js
index 4dc5ab3..673662a 100644
--- src/hg/js/hgSearch.js
+++ src/hg/js/hgSearch.js
@@ -792,35 +792,36 @@
         window.location = window.location.href.replace(re,"db="+newDb);
     }
 
     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 (cartJson.db !== undefined) {
                 db = cartJson.db;
             } else {
                 alert("Error no database from request");
             }
-            if (cartJson.warning !== undefined) {
+            if (typeof cartJson.warning !== undefined) {
                 alert("Warning: " + cartJson.warning);
             }
             // check right away for a special redirect to hgTracks:
-            if (cartJson.positionMatches !== undefined &&
+            if (typeof cartJson.warning === undefined &&
+                    cartJson.positionMatches !== undefined &&
                     cartJson.positionMatches.length == 1 &&
                     cartJson.positionMatches[0].matches[0].doRedirect === true) {
                 positionMatch = cartJson.positionMatches[0];
                 match = positionMatch.matches[0];
                 position = match.position;
                 newUrl = "../cgi-bin/hgTracks" + "?db=" + db + "&position=" + position;
                 if (match.highlight) {
                     newUrl += "&addHighlight=" + match.highlight;
                 }
                 if (positionMatch.name !== "chromInfo") {
                     newUrl += "&" + positionMatch.name + "=pack";
                 }
                 window.location.replace(newUrl);
             }
             var urlParts = {};