bc49261bb4a82b6b0068c069e5807e4f7e4420e7
max
  Wed Oct 16 10:00:02 2024 -0700
bugfix, go over the deleted tracks, not all of trackDb. refs #27890

diff --git src/hg/js/utils.js src/hg/js/utils.js
index 8998d26..14f36fe 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -488,38 +488,43 @@
         if (!familySize.hasOwnProperty(topParent)) {
             familySize[topParent] = 0;
             families[topParent] = [];
         }
         familySize[topParent]++;
         families[topParent].push(trackName);
     }
 
     // decrease the parent's count for each track to delete
     for (var delTrack of delTracks) {
         var tdbRec = hgTracks.trackDb[delTrack];
         if (tdbRec.topParent)
             familySize[tdbRec.topParent]--;
     }
 
-    // for the parents with a count of 0, create an array of [parentName, children]
+    // for the parents of deleted tracks with a count of 0, create an array of [parentName, children]
     loneParents = [];
-    for (var parentName of Object.keys(familySize)) {
+    for (delTrack of delTracks) {
+        var parentName = hgTracks.trackDb[delTrack].topParent;
+        if (parentName) {
             if (familySize[parentName]===0)
                 loneParents.push([parentName, families[parentName]]);
             else
                 for (var child of families[parentName])
                     others.push(child);
+        } else {
+            others.push(delTrack);
+        }
     }
 
     o = {};
     o.loneParents = loneParents;
     o.others = others;
     return o;
 }
 
 function aryFind(ary,val)
 {// returns the index of a value on the array or -1;
     for (var ix=0; ix < ary.length; ix++) {
         if (ary[ix] === val) {
             return ix;
         }
     }