532df37bf012ea6b52943707aaa6ab4a8b4f379f
max
  Fri Oct 25 14:50:53 2024 -0700
hide others is getting worse and worse, need to address case that track to hide is a child itself and the problem that superTrack visibility is NOT (!) inherited by children. Encode regulation can be at hide, but the children are visible! refs #27890

diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 90776a9..5de1d29 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -2144,63 +2144,56 @@
     },
     hideTracks: function (ids)
     {
         var cartVars = [];
         var cartVals = [];
 
         // find parent tracks that are losing all their children (lone parents)
         var familyAnalysis = tdbFindChildless(hgTracks.trackDb, ids);
 
         // lone parents get special treatment
         for (var delFam of familyAnalysis.loneParents) {
             var loneParent = delFam[0];
             var loneParentChildren = delFam[1];
 
             // remove all the lone parent children now from the track image
+            // and also unselect them, if they are children of a composite
             for (var childName of loneParentChildren) {
                 $(document.getElementById('tr_' + childName)).remove();
+                var rec = hgTracks.trackDb[childName];
+                // the following means that all composite children are always unselected, so you cannot get the
+                // current selection easily back, since we always hide them all, instead of just hiding the parent.
+                // The problem is that it's not easy to find out if there is an easier way to hide them, the code
+                // would have to go over all possible parents, not just topParents. Maybe one day.
+                if (tdbIsSubtrack(rec)) {
+                    cartVars.push(childName+"_sel");
+                    cartVals.push('0');
+                }
             }
 
             // and set the lone parent to hide in the cart and also in the track list below
             cartVars.push(loneParent);
             cartVals.push('[]');
+             
             vis.update(loneParent, 'hide');
         }
 
         // handle all other tracks, they are either not parents or parents with at least one child left
         var delIds = familyAnalysis.others;
         for (var i = 0; i<delIds.length; i++) {
             var id = delIds[i];
-            var rec = hgTracks.trackDb[id];
-            if (tdbIsSubtrack(rec)) {
-                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
-                cartVars.push(id);
-                cartVals.push('hide');
-
-                cartVars.push(id+"_sel");
-                cartVals.push(0);
-            } else {
-                // normal, top-level track
-                cartVars.push(id);
-                cartVals.push('hide');
-            }
+            cartHideAnyTrack(id, cartVars, cartVals);
             $(document.getElementById('tr_' + id)).remove();
         }
         imageV2.afterImgChange(true);
         cart.setVars( cartVars, cartVals );
     },
 
     hideOthers: function (id) {
         /* hide all tracks but 'id'. Hide parents of composites/folders, rather than their children */
         var myParent = hgTracks.trackDb[id].parentTrack;
 
         var hideList = [];
         for (var otherId in hgTracks.trackDb) {
             if (otherId===id || otherId==="ruler")
                 continue;
 
@@ -3018,30 +3011,38 @@
                         menu.push(o);
                     }
                 }
             }
 
 
             menu.push($.contextMenu.separator);
             o = {};
             o[" Hide all other tracks "] = {
                 onclick: function(menuItemClicked, menuObject) {
                     rightClick.hit(menuItemClicked, menuObject, "hideOthers");
                     return true; }
             };  
             menu.push(o);
 
+            //o = {};
+            //o[" Float "] = {
+                //onclick: function(menuItemClicked, menuObject) {
+                    //rightClick.hit(menuItemClicked, menuObject, "float");
+                    //return true; }
+            //};  
+            //menu.push(o);
+
             o = {};
             o[" Move to top "] = {
                 onclick: function(menuItemClicked, menuObject) {
                     rightClick.hit(menuItemClicked, menuObject, "moveTop");
                     return true; }
             };  
             menu.push(o);
 
             o = {};
             o[" Move to bottom "] = {
                 onclick: function(menuItemClicked, menuObject) {
                     rightClick.hit(menuItemClicked, menuObject, "moveBottom");
                     return true; }
             };  
             menu.push(o);