c9714d23710a9089473f5caafe6ec01934755a11
chmalee
  Fri Mar 27 09:37:09 2026 -0700
Save position ranges search on hgGateway to the recent positions stack, refs #34588

diff --git src/hg/js/hgGateway.js src/hg/js/hgGateway.js
index 9e2b1134e12..85240aa9215 100644
--- src/hg/js/hgGateway.js
+++ src/hg/js/hgGateway.js
@@ -1739,30 +1739,36 @@
             }
         }
         function onFail(jqXHR, textStatus) {
             window.location.assign("../cgi-bin/hgSearch?search=" + searchTerm  + "&hgsid="+ window.hgsid );
         }
         var canonMatch = position.match(canonicalRangeExp);
         var gbrowserMatch = position.match(gbrowserRangeExp);
         var lengthMatch = position.match(lengthRangeExp);
         var bedMatch = position.match(bedRangeExp);
         var sqlMatch = position.match(sqlRangeExp);
         var singleMatch = position.match(singleBaseExp);
         var gnomadRangeMatch = searchTerm.match(gnomadRangeExp);
         var gnomadVarMatch = searchTerm.match(gnomadVarExp);
         var positionMatch = canonMatch || gbrowserMatch || lengthMatch || bedMatch || sqlMatch || singleMatch || gnomadRangeMatch || gnomadVarMatch;
         if (positionMatch !== null || goDirectlyToHgTracks) {
+            if (positionMatch !== null) {
+                // about to do a form submit with a regular position range, save this to the recents stack
+                // strip any html content first
+                let newPos = position.replace(/<[^>]*>/g, '');
+                addRecentSearch(getDb(), newPos, {id: newPos, value: newPos, label: newPos});
+            }
             // We already have a position from either selecting a suggestion or the user just typed a regular
             // old position, so go to hgTracks at that location
             // Show a spinner -- sometimes it takes a while for hgTracks to start displaying.
             $('.jwGoIcon').removeClass('fa-play').addClass('fa-spinner fa-spin');
             // Make a form and submit it.  In order for this to work in IE, the form
             // must be appended to the body.
             $('body').append($form);
             $form.trigger("submit");
         } else {
             // User has entered a search term with no suggestion, go to the disambiguation
             // page so the user can choose a position
             // redirect to hgBlat if the input looks like a DNA sequence
             // minimum length=19 so we do not accidentally redirect to hgBlat for a gene identifier 
             // like ATG5
             var dnaRe = new RegExp("^(>[^\n\r ]+[\n\r ]+)?(\\s*[actgnACTGN \n\r]{19,}\\s*)$");