1b1a0aa39ffd5c18dbb425fca096ea335ed154fe max Wed Mar 25 06:42:39 2026 -0700 superTrack hgTrackUi: auto-hide when all children hidden, grey dropdown on hide refs #37282 Route button clicks through superT.selChanged() by triggering the dropdown change event instead of just setting its value. This fixes three problems: (1) hiding all subtracks now auto-hides the superTrack container (matching composite track behavior), (2) the superTrack show/hide dropdown greys out when set to hide, and (3) clicking Hide on a subtrack no longer forces the superTrack to show. This makes the code actually simpler. I didn't know about selChanged() when I wrote the new superTrack code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c index cd3185f9527..aac0af2cdb3 100644 --- src/hg/hgTrackUi/hgTrackUi.c +++ src/hg/hgTrackUi/hgTrackUi.c @@ -2863,49 +2863,57 @@ printf("</TD>\n<TD>"); printf("%s ",tdb->shortLabel); } printf("</TD>\n"); printf("<TD>%s", tdb->longLabel); printf(" "); printDataVersion(database, tdb); //printf(" <EM style='color:#666666; font-size:smaller;'>%s</EM>", dataVersion); printf("</TD></TR>"); } printf("</TABLE>"); // Now configure the elements above with Javascript: -// * Clicking a button sets the dropdown to the button's text +// * Clicking a button sets the dropdown to the button's text and triggers change +// so superT.selChanged() runs (handles checkbox sync, hiddenText class, auto-show/hide superTrack) jsOnEventBySelector("click", ".seg-btn-group > button", "let dropdown = $('[name=\"' + $(this).parent().data('trackname')+'\"]'); " // cannot use #id, . has special meaning "let buttonText=$(this).text().toLowerCase(); " - "dropdown.val(buttonText).removeClass('hiddenText').addClass('normalText');" + "dropdown.val(buttonText).trigger('change');" ); // * Clicking buttons does not submit the form (default action of <button> is to submit, unless type=button) jsInline("$('.seg-btn-group button').attr('type', 'button');"); -// * Clicking buttons makes them pressed. Also, clicking any button shows the superTrack +// * Clicking buttons makes them pressed jsInline("$('.seg-btn-group').on('click', 'button', function() {" "$(this).addClass('seg-active').siblings().removeClass('seg-active');" - "$('.superDropdown').val('show');" "});"); // * Changing the dropdown updates the buttons jsInline("$('#superTrackTable .vizSelect').on('change', function() {" "$(this).next().children().removeClass('seg-active');" "let labelToFind = capitalizeFirstLetter($(this).val());" "$(this).next().find('button').filter(function() { return $(this).text().trim() === labelToFind; }).addClass('seg-active');" "});"); +// * Grey out the superTrack dropdown when manually set to hide +jsInline("$('.superDropdown').on('change', function() {" + "if ($(this).val() === 'hide') {" + "$(this).removeClass('normalText').addClass('hiddenText');" + "} else {" + "$(this).removeClass('hiddenText').addClass('normalText');" + "}" + "});"); // * Hide all subtrack dropdowns from the user. They are used so the CGI arguments // are sent to hgTracks, but are not necessary as UI elements anymore jsInline("$('#superTrackTable .vizSelect').hide();"); } #ifdef USE_HAL static void cfgHalSnake(struct trackDb *tdb, char *name) { boolean parentLevel = isNameAtParentLevel(tdb, name); if (parentLevel) return; char *fileName = trackDbSetting(tdb, "bigDataUrl"); if (fileName == NULL) return; char *errString;