42f1dc531b4d7d739a1c28b552c4c7dd21823390
chmalee
  Wed Aug 12 10:04:30 2020 -0700
Move printing of hub search results div to after we've made sure we got a search result, refs #26013

diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index 21ca414..743e1f2 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -1266,36 +1266,36 @@
  * match the db filter.
  * If there are no search results to print, the basic hub lines are combined into a single HTML table
  * that is defined outside this function.
  * Otherwise, each hub line is printed in its own table followed by a <ul> containing details
  * about the search results. */
 {
 if (hubSearchResult != NULL)
     printf("<table class='hubList'><tbody>\n");
 outputPublicTableRow(hubInfo, count);
 if (hubSearchResult != NULL)
     {
     printf("</tbody></table>\n");
     struct trackHub *hub = fetchTrackHub(hubInfo);
     if (hub != NULL)
         {
-        printf("<div class=\"hubTdbTree\">\n");
-        printf("<div id='tracks%d'></div>", hubInfo->id); // div for the jstree for this hub's search result(s)
-        printf("</div>\n");
         struct hubOutputStructure *hubOut = buildHubSearchOutputStructure(hub, hubSearchResult);
         if (dyStringIsEmpty(hubOut->descriptionMatch) && (hubOut->genomes == NULL))
             return; // no detailed search results; hit must have been to hub short label or something
+        printf("<div class=\"hubTdbTree\">\n");
+        printf("<div id='tracks%d'></div>", hubInfo->id); // div for the jstree for this hub's search result(s)
+        printf("</div>\n");
         printHubOutputStructure(hubOut, hubInfo);
         }
     }
 }
 
 int hubEntryCmp(const void *va, const void *vb)
 /* Compare to sort based on shortLabel */
 {
 const struct hubEntry *a = *((struct hubEntry **)va);
 const struct hubEntry *b = *((struct hubEntry **)vb);
 
 return strcasecmp(a->shortLabel, b->shortLabel);
 }