2d820c127e278ecf3e4162048ddef02544a2b5ff
chmalee
  Wed Jul 28 11:27:17 2021 -0700
Make hgTrackUi pop-up control on hgTracks inner data scrollable, which prevents the pop-up window from extending past the bottom of the screen, in turn fixing the always would have been hidden submit buttons, refs #20242

diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index fb9b2d9..955e692 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -3619,30 +3619,42 @@
             minHeight: 200,
             minWidth: 400,
             maxHeight: popMaxHeight,
             maxWidth: popMaxWidth,
             modal: true,
             closeOnEscape: true,
             autoOpen: false,
             buttons: uiDialogButtons,
 
             // popup.ready() doesn't seem to work in open.
             open: function(event) {
                 // fix popup to a location -- near the top and somewhat centered on the browser image
                 $(event.target).parent().css('position', 'fixed');
                 $(event.target).parent().css('top', '18%');
                 $(event.target).parent().css('left', '30%');
+                var containerHeight = $(event.target).parent().height();
+                var offsetTop = $(event.target).parent()[0].offsetTop;
+                // from popMaxHeight calculation above:
+                var offsetBottom = 40;
+                var maxContainerHeight = $(window).height() - offsetTop - offsetBottom;
+                if (containerHeight > maxContainerHeight) {
+                    $(event.target).parent().css('height', maxContainerHeight);
+                    // the 100 below accounts for the buttons, and label, there is
+                    // probably a better way to get the exact size of the container
+                    // with no content
+                    $(event.target).css('height', maxContainerHeight - 100);
+                }
 
                 if (!popUp.trackDescriptionOnly) {
                     $('#hgTrackUiDialog').find('.filterBy,.filterComp').each(
                         function(i) {
                             if ($(this).hasClass('filterComp'))
                                 ddcl.setup(this);
                             else
                                 ddcl.setup(this, 'noneIsAll');
                         }
                     );
                 }
             },
             close: function() {
                 popUp.cleanup();
             }