aa0d552ae6d3f9eef21dd6697c7f1e27bbe070cd
max
  Wed Jan 8 03:10:23 2025 -0800
fixing the nested case for right-click hide, refs #34959

diff --git src/hg/js/utils.js src/hg/js/utils.js
index 468d19a..92f9928 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -541,34 +541,36 @@
             compLinks.familySize[parentName]--;
 
         parentName = tdbRec.topParent;
         if (parentName)
             topLinks.familySize[parentName]--;
     }
 
     // for the parents of deleted tracks with a count of 0, create an array of [parentName, children]
     var loneParents = [];
     var doneParents = [];
     for (delTrack of delTracks) {
         var parentName = hgTracks.trackDb[delTrack].parentTrack;
         var topParentName = hgTracks.trackDb[delTrack].topParent;
         if (parentName) {
             // hide a superTrack parent only if that superTrack does not have any other tracks open
+            // This addresses the case where you hide the last child of a composite under a superTrack
+            // E.g. All Gencode / Gencode V46 or FANTOM5/Max count 
             if (compLinks.familySize[parentName]===0 && topLinks.familySize[topParentName]===0) {
                 if (!doneParents.includes(parentName)) {
-                    loneParents.push([parentName, compLinks.families[parentName]]);
-                    doneParents.push(parentName);
+                    loneParents.push([topParentName, compLinks.families[parentName]]);
+                    doneParents.push(topParentName);
                 }
             } else
                 for (var child of compLinks.families[parentName])
                     // do not hide tracks of lone parents that are not in delTracks
                     if (delTracks.includes(child))
                         others.push(child);
         } else {
             others.push(delTrack);
         }
     }
 
     o = {};
     o.loneParents = loneParents;
     o.others = others;
     return o;