77cfc90b4fb2166b9ae955ad40a067549d6d5881
max
  Tue Sep 15 05:29:56 2026 -0700
hgc share-a-link: force the enclosing superTrack to show

The hgc details-page "Share a link" button strips the hgsid and links straight
to the page, but a track nested in a superTrack draws nothing on a fresh load
of that link since superTracks default to hide. Add tdbTopSuperTrack() so the
per-track JSON carries the enclosing superTrack's name, and have the share
dialog force <superTrack>=show onto the URL when there is one.

diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 4b20c81b4b0..8f17edec7ec 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -5276,32 +5276,38 @@
         cleanHtml = stripMainMenu(cleanHtml, false, nonceJs); // DEBUG msg with true
 
         // this is dumb but all relative links need to be stripped of _target = blank so we
         // can jump down the page rather than out to a new tab
         cleanHtml = cleanHtml.replace(/_target ?= ?["']blank["']/g,"");
 
         // "Share a link" at the top of the popup: shares a link to this details page
         // (the hgc URL with the hgsid stripped), handled by topLinks.js.
         var shareBar = "<div id='hgcShareBar' style='margin:0 0 8px 0; text-align:right;'>" +
             "<a id='hgcShareLink' href='#'>Share a link</a></div>";
         $('#hgcDialog').html("<div id='pop' style='font-size:1.1em;'>"+ shareBar + cleanHtml +"</div>");
         $('#hgcShareLink').on("click", function(e) {
             e.preventDefault();
             // Share the details-page URL with hgsid stripped; keep (or add) db so it opens
             // standalone, and note that the link shows the page, not the user's active tracks.
-            if (window.topLinks && window.topLinks.shareUrl)
-                window.topLinks.shareUrl(popUpHgcOrHgGene.href, {ensureDb: getDb(), pageNote: true});
+            // If this track lives inside a superTrack, force that superTrack to "show" in the
+            // link too -- superTracks default to hide, so without this the linked-to track
+            // would come up invisible on a fresh page load.
+            if (window.topLinks && window.topLinks.shareUrl) {
+                var rec = hgTracks.trackDb[popUpHgcOrHgGene.table];
+                window.topLinks.shareUrl(popUpHgcOrHgGene.href,
+                    {ensureDb: getDb(), pageNote: true, superTrack: rec && rec.superTrack});
+            }
         });
         appendNonceJsToPage(nonceJs);
         let subtrack = tdbIsSubtrack(hgTracks.trackDb[popUpHgcOrHgGene.table]) ? popUpHgcOrHgGene.table : "";
         popUpHgcOrHgGene.saveAllVars = getAllVars( $('#hgcDialog'), subtrack );
 
 
 
         // Strategy for popups with js:
         // - jsFiles and CSS should not be included in html.  Here they are shluped out.
         // - The resulting files ought to be loadable dynamically (with getScript()),
         //   but this was not working nicely with the modal dialog
         //   Therefore include files must be included with hgc CGI !
         // - embedded js should not be in the popup box.
         // - Somethings should be in a popup.ready() function, and this is emulated below,
         //   as soon as the cleanHtml is added