814472876eac4d004d61f0ed89bd2aaa07459d33
max
  Thu Apr 9 06:42:24 2026 -0700
Fix composite vis: prefer pack over full, fix [-] button hide, refs #37182

Two issues from QA (note-17):

1) exposeAll() and onUserCbChange() always set composite to "full" when
re-enabling subtracks on tracks without a "pack" option. Now tries
pack first, then dense, then full as last resort.

2) The matrix [-] button (btn_minus_all_left_top) did not hide the
composite. _matSetMatrixCheckBoxes() called hideAll() which triggered
propagateVis, and propagateVis re-checked all subCBs when
checkedCount===0, undoing the hide. Fix: set composite to hide
directly via prop('selectedIndex', 0) without triggering propagateVis.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

diff --git src/hg/js/subCfg.js src/hg/js/subCfg.js
index e2ca2dd1025..4a845136f5b 100644
--- src/hg/js/subCfg.js
+++ src/hg/js/subCfg.js
@@ -60,33 +60,39 @@
 		}
             }
         }
     },
 
     // Called only on real user clicks (bound via native addEventListener, not jQuery,
     // so jQuery .trigger('change') calls during init do not reach this).
     // Handles both subCB and matCB clicks.
     onUserCbChange: function () {
         var compEl = $("[name='"+subCfg.compositeName+"']");
         if (compEl.length === 0)
             return;
 
         var anyChecked = $(".subCB:checked:visible").length > 0;
 
-        // if any subtracks are now checked and the composite is on hide, set it to pack
-        if (anyChecked && compEl.val() === "hide")
+        // if any subtracks are now checked and the composite is on hide, set it to pack (or dense)
+        if (anyChecked && compEl.val() === "hide") {
+            if (compEl.children('option[value="pack"]').length)
                 compEl.val("pack").change();
+            else if (compEl.children('option[value="dense"]').length)
+                compEl.val("dense").change();
+            else
+                compEl.prop('selectedIndex', compEl.children('option').length - 1).change();
+        }
 
         // if no subtracks are checked, set the composite to hide
         if (!anyChecked)
             compEl.val("hide");
     },
 
     clearChange: function (obj)
     { // Mark as unchanged
         $(obj).removeClass('changed');
 
         // checkboxes have hidden boolshads which should be cleared in tandem
         if (obj.type === "checkbox") {
             var boolshad = normed($("input.cbShadow#boolshad\\."+obj.id));
             if (boolshad) {
                 $(boolshad).removeClass('changed');