3e6f2d19667afbc81cc78d76d4ea08a4540edeed
max
  Fri Oct 4 06:02:36 2024 -0700
only hiding parents when doing "hide all others", refs #23793

diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index f7cc4ad..da49ce9 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -2127,61 +2127,72 @@
     clickedHighlightIdx : null,  // the index (0,1,...) of the highlight item that overlaps the last right-click
 
     moveTo : function(id, topOrBottom) {
         /* move a track to either "top" or "bottom" position */
         let newPos = "0.5";
         if (topOrBottom==="bottom") {
             newPos = String(parseInt($(".imgOrd").last().attr("abbr"))+1);
         }
 
         let trEl = $(document.getElementById('tr_' + id));
         trEl.attr('abbr', newPos);
 
         dragReorder.sort($("#imgTbl"));
         dragReorder.setOrder($("#imgTbl"));
     },
-    hideTracks: function (ids) 
+    hideTracks: function (ids, hideParent) 
     {
         var cartVars = [];
         var cartVals = [];
 
         for (var i = 0; i<ids.length; i++) {
             var id = ids[i];
             var rec = hgTracks.trackDb[id];
+            if (hideParent) {
+                // only hide the parent, not children
+                $(document.getElementById('tr_' + id)).remove();
+                if (tdbHasParent(rec) && tdbIsLeaf(rec)) {
+                    id = rec.parentTrack;
+                }
+                cartVars.push(id);
+                cartVals.push('hide');
+            }
+            else { 
                 if (tdbIsSubtrack(rec)) {
                     // Remove subtrack level vis and explicitly uncheck.
                     //cart.setVars( [ id, id+"_sel" ], [ '[]', 0 ] ); 
                     cartVars.push(id);
                     cartVals.push('[]');
 
                     cartVars.push(id+"_sel");
                     cartVals.push(0);
                 } else if (tdbIsFolderContent(rec)) {
                     // supertrack children need to have _sel set to trigger superttrack reshaping
                     //cart.setVars( [ id, id+"_sel" ], [ 'hide', 0 ] ); 
                     cartVars.push(id);
                     cartVals.push('hide');
 
                     cartVars.push(id+"_sel");
                     cartVals.push(0);
                 } else {
                     //cart.setVars([id], ['hide']);  // Others, just set vis hide.
                     cartVars.push(id);
                     cartVals.push('hide');
                 }
                 $(document.getElementById('tr_' + id)).remove();
             }
+        }
         imageV2.afterImgChange(true);
         cart.setVars( cartVars, cartVals );
     },
 
     makeMapItem: function (id)
     {   // Create a dummy mapItem on the fly
         // (for objects that don't have corresponding entry in the map).
         if (id && id.length > 0 && hgTracks.trackDb) {
             var title;
             var rec = hgTracks.trackDb[id];
             if (rec) {
                 title = rec.shortLabel;
             } else {
                 title = id;
             }
@@ -2473,31 +2484,31 @@
                 async: false,
                 url: "../cgi-bin/hgCollection",
                 data: "cmd=addTrack&track=" + id + "&collection=" + collectionName + "&hgsid=" + getHgsid(),
                 trueSuccess: mySuccess,
                 success: catchErrorOrDispatch,
                 error: errorHandler,
             });
 
             imageV2.fullReload();
         } else if (cmd === "hideOthers") {
             var hideIds = [];
             for (var otherId in hgTracks.trackDb) {
                 if (otherId!==id && otherId!=="ruler") 
                     hideIds.push(otherId);
             }
-            rightClick.hideTracks(hideIds);
+            rightClick.hideTracks(hideIds, true);
         } else if (cmd === "moveTop") {
             rightClick.moveTo(id, "top");
         } else if (cmd === "moveBottom") {
             rightClick.moveTo(id, "bottom");
         } else if ((cmd === 'sortExp') || (cmd === 'sortSim')) {
             url = "hgTracks?hgsid=" + getHgsid() + "&" + cmd + "=";
             rec = hgTracks.trackDb[id];
             if (tdbHasParent(rec) && tdbIsLeaf(rec))
                 url += rec.parentTrack;
             else {
                 // The button already has the ref
                 var link2 = normed($( 'td#td_btn_'+ rightClick.selectedMenuItem.id ).children('a')); 
                 if (link2)
                     url = $(link2).attr('href');
                 else
@@ -2645,31 +2656,31 @@
                 updateObj[key] = 1;
                 cart.setVarsObj(updateObj,null,false);
                 imageV2.requestImgUpdate(id, id + ".doMergeItems=1");
             }
         } else {   // if ( cmd in 'hide','dense','squish','pack','full','show' )
             // Change visibility settings:
             //
             // First change the select on our form:
             rec = hgTracks.trackDb[id];
             selectUpdated = vis.update(id, cmd);
 
             // Now change the track image
             if (imageV2.enabled && cmd === 'hide') {
                 // Hide local display of this track and update server side cart.
                 // Subtracks controlled by 2 settings so del vis and set sel=0.
-                rightClick.hideTracks([id]);
+                rightClick.hideTracks([id], false);
             } else if (!imageV2.mapIsUpdateable) {
                 jQuery('body').css('cursor', 'wait');
                 if (selectUpdated) {
                     // assert(document.TrackForm);
                     document.TrackForm.submit();
                 } else {
                         // Add vis update to queue then submit
                         cart.setVars([id], [cmd], null, false); // synchronous
                         document.TrackHeaderForm.submit();
                 }
             } else {
                 imageV2.requestImgUpdate(id, id + "=" + cmd, "", cmd);
             }
         }
     },