4ddbd4de63bff1948c81c6b84aa9334cdadeeb8c
braney
  Fri Aug 20 17:48:25 2021 -0700
restore the watermark in the position box if we update the hgTracks
image.   refs #27728

diff --git src/hg/js/autocomplete.js src/hg/js/autocomplete.js
index 4a05f5b..41bce2a 100644
--- src/hg/js/autocomplete.js
+++ src/hg/js/autocomplete.js
@@ -50,48 +50,35 @@
         // highlight genes choosen from suggest list (#6330)
         if ($('#hgFindMatches').length) $('#hgFindMatches').val(val);
         else $('#positionInput').parents('form').append("<input type='hidden' id='hgFindMatches' name='hgFind.matches' " + "value='" + val + "'>");
     },
 
     initialized: false,
 
     lastMouseDown : null,
 
     init: function(db, assemblySupportsGeneSuggest, selectCallback, clickCallback) {
         // selectCallback(item): called when the user selects a new genomic position from the list
         // clickCallback(position): called when the user clicks on positionDisplay
         this.initialized = true;
         var lastSelected = null; // this is the last value entered by the user via a suggestion (used to distinguish manual entry in the same field)
         var $posInput = $('#positionInput');
-        var waterMark;
-        if (assemblySupportsGeneSuggest) {
-            if (db.match(/^hg[0-9]+/)) {
-                // Mention HGVS variant notation for human assemblies only, although it should work
-                // with any assembly that has refGene or ncbiRefSeq.
-                waterMark = "enter position, gene symbol, HGVS or search terms";
-            } else {
-                waterMark = "enter position, gene symbol or search terms";
-            }
-        } else {
-            waterMark = "enter position or search terms";
-        }
-
         if ($posInput[0] !== document.activeElement) {
             // Reset value before adding watermark -- only if user is not already typing here
             $posInput.val("");
         }
-        $posInput.Watermark(waterMark, '#686868');
+        var waterMark = suggestBox.restoreWatermark(db, assemblySupportsGeneSuggest);
         if (assemblySupportsGeneSuggest) {
             $('#positionInput').autocomplete({
                 delay: 500,
                 minLength: 2,
                 source: this.ajaxGet(db),
                 open: function(event, ui) {
                     var pos = $(this).offset().top + $(this).height();
                     if (!isNaN(pos)) {
                         var maxHeight = $(window).height() - pos - 30; // take off a little more because IE needs it
                         var auto = $('.ui-autocomplete');
                         var curHeight = $(auto).children().length * 21;
                         if (curHeight > maxHeight) $(auto).css({
                             maxHeight: maxHeight + 'px',
                             overflow: 'scroll',
                             zIndex: 12
@@ -136,17 +123,39 @@
             lastMouseDown = event.offsetX;
         });
 
         $("#positionDisplay").mouseup(function(event) {
             if (event.offsetX !== lastMouseDown)
                 return; 
             // this let's the user click on the genomic position (e.g. if they want to edit it)
             clickCallback($(this).text());
             $('#positionInput').val($(this).text());
             suggestBox.clearFindMatches();
             if (hgTracks.windows)
                 {
                 genomePos.positionDisplayDialog();
                 }
         });
+    },
+
+    restoreWatermark: function(db, assemblySupportsGeneSuggest) {
+        var waterMark;
+        var $posInput = $('#positionInput');
+        if (assemblySupportsGeneSuggest) {
+            if (db.match(/^hg[0-9]+/)) {
+                // Mention HGVS variant notation for human assemblies only, although it should work
+                // with any assembly that has refGene or ncbiRefSeq.
+                waterMark = "enter position, gene symbol, HGVS or search terms";
+            } else {
+                waterMark = "enter position, gene symbol or search terms";
             }
+        } else {
+            waterMark = "enter position or search terms";
+        }
+            //$('input[name="hgt.positionInput"]').val("");
+        $posInput.val("");
+        $posInput.Watermark(waterMark, '#686868');
+
+        return waterMark;
+    }, 
+
 };