c8eef4a1e85bcfd8b41e87e287cbf15f09fc357a
jcasper
  Sun Aug 16 22:19:22 2020 -0700
Replacing beforeUnload synchronous updates (blocked by Chrome) with async updates.
Also fixing the suggestion box, so following a suggestion turns on the track and highlights the item.
refs #25017, #25703

diff --git src/hg/js/autocomplete.js src/hg/js/autocomplete.js
index d7734cb..4a05f5b 100644
--- src/hg/js/autocomplete.js
+++ src/hg/js/autocomplete.js
@@ -92,33 +92,33 @@
                         var auto = $('.ui-autocomplete');
                         var curHeight = $(auto).children().length * 21;
                         if (curHeight > maxHeight) $(auto).css({
                             maxHeight: maxHeight + 'px',
                             overflow: 'scroll',
                             zIndex: 12
                         });
                         else $(auto).css({
                             maxHeight: 'none',
                             overflow: 'hidden',
                             zIndex: 12
                         });
                     }
                 },
                 select: function(event, ui) {
-                    selectCallback(ui.item);
                     lastSelected = ui.item.value;
                     suggestBox.updateFindMatches(ui.item.internalId);
+                    selectCallback(ui.item);
                     // jQuery('body').css('cursor', 'wait');
                     // document.TrackHeaderForm.submit();
                 }
             });
         }
 
         // I want to set focus to the suggest element, but unforunately that prevents PgUp/PgDn from
         // working, which is a major annoyance.
         // $('#positionInput').focus();
         $("#positionInput").change(function(event) {
             if (!lastSelected || lastSelected !== $('#positionInput').val()) {
                 // This handles case where user typed or edited something rather than choosing from a suggest list;
                 // in this case, we only change the position hidden; we do NOT update the displayed coordinates.
                 var val = $('#positionInput').val();
                 // handles case where users zeroes out positionInput; in that case we revert to currently displayed position