e5d2a3ffc3900795526144f1834612cd8c9ddf24
chmalee
  Wed May 20 12:25:29 2026 -0700
Fix last two remaining bugs from #37411: genome name and hub name should be defaults if you click upload from the hubSpace top level, and should update appropriatly if you select a previously uploaded assembly hub genome from the genome dropdown list, refs #37411

diff --git src/hg/js/hgMyData.js src/hg/js/hgMyData.js
index d4d5cd17757..86e84d8f27d 100644
--- src/hg/js/hgMyData.js
+++ src/hg/js/hgMyData.js
@@ -221,46 +221,50 @@
                 // keep these as a variable so we can init the autocompleteCat
                 // code only after the elements have actually been rendered
                 // there are multiple rendering passes and only eventually
                 // do the elements actually make it into the DOM
                 let ret = h('div', {
                         class: "uppy-Dashboard-FileCard-label",
                         style: "display: inline-block; width: 78%"
                         },
                     // first child of div
                     "Select from popular assemblies:",
                     // second div child
                     h('select', {
                         id: `${file.meta.name}DbSelect`,
                         style: "margin-left: 5px",
                         onChange: e => {
-                            onChange(e.target.value);
-                            file.meta.genome = e.target.value;
-                            file.meta.genomeLabel = e.target.selectedOptions[0].label;
-                            // If the user picked one of their own assembly hubs,
-                            // flip hubType and align parentDir so the upload
-                            // targets that existing hub rather than creating a
-                            // new stub. If they picked a UCSC db, flip back
-                            // and reset parentDir to a fresh default so they
-                            // don't accidentally upload into an assembly hub.
-                            let hub = hubCreate.assemblyHubByGenome(e.target.value);
-                            if (hub) {
-                                file.meta.hubType = "assemblyHub";
-                                file.meta.parentDir = hub.fileName;
-                            } else {
-                                file.meta.hubType = "trackHub";
-                                file.meta.parentDir = hubCreate.uiState.hubNameDefault;
+                            let val = e.target.value;
+                            let label = e.target.selectedOptions[0].label;
+                            let hub = hubCreate.assemblyHubByGenome(val);
+                            let newParentDir = hub ? hub.fileName : hubCreate.uiState.hubNameDefault;
+                            // Uppy's file card keeps controlled-input
+                            // state per field and commits it to meta on
+                            // Upload, overwriting setFileMeta. Route
+                            // genome through the field-level onChange and
+                            // force the Hub Name input value to match.
+                            onChange(val);
+                            uppy.setFileMeta(file.id, {
+                                genomeLabel: label,
+                                hubType: hub ? "assemblyHub" : "trackHub",
+                                parentDir: newParentDir,
+                            });
+                            let pd = document.getElementById("uppy-Dashboard-FileCard-input-parentDir");
+                            if (pd) {
+                                pd.value = newParentDir;
+                                pd.dispatchEvent(new Event("input", {bubbles: true}));
+                                pd.dispatchEvent(new Event("change", {bubbles: true}));
                             }
                         }
                         },
                         hubCreate.makeGenomeSelectOptions(file.meta.genome, file.meta.genomeLabel).map( (genomeObj) => {
                             return h('option', {
                                 value: genomeObj.value,
                                 label: genomeObj.label,
                                 selected: file.meta.genome !== null ? genomeObj.value === file.meta.genome : genomeObj.value === hubCreate.defaultDb()
                             });
                         })
                     ),
                     h('p', {
                         class: "uppy-Dashboard-FileCard-label",
                         style: "display: block; width: 78%",
                         }, "or search for your genome:"),
@@ -889,68 +893,40 @@
                 "genome": hubCreate.defaultDb(),
                 "fileType": ftype,
                 "parentDir": defaultParentDir,
                 "hubType": "trackHub",
             };
             if (ftype === "2bit") {
                 // This file defines an assembly hub. Default the genome to the
                 // sanitized filename stem; the user can edit it in the file card.
                 defaultMeta.genome = hubCreate.sanitizeGenomeName(file.name);
                 defaultMeta.genomeLabel = defaultMeta.genome;
                 defaultMeta.hubType = "assemblyHub";
             }
             this.uppy.setFileMeta(file.id, defaultMeta);
 
             // When drilled into an assembly hub, inherit and lock its genome.
-            let drilledIntoAsmHub = false;
             if (hubCreate.uiState.currentHub &&
                 hubCreate.uiState.currentHub === defaultMeta.parentDir) {
                 let existing = hubCreate.uiState.filesHash[defaultMeta.parentDir];
                 if (existing && existing.hubType === "assemblyHub") {
                     this.uppy.setFileMeta(file.id, {
                         genome: existing.genome,
                         genomeLabel: existing.genome,
                         hubType: "assemblyHub",
                         genomeLocked: true,
                     });
-                    drilledIntoAsmHub = true;
-                }
-            }
-
-            // Top-level with no drilled-in hub: if the user already has an
-            // assembly hub, default this file to target it so they don't have
-            // to re-enter the genome + hub name. The user can still switch via
-            // the dropdown. Skip this when the file itself is hub-defining
-            // (2bit or hub.txt) or when any file in the batch is - in that
-            // case the batch is creating a *new* hub, not adding to an
-            // existing one, so the defaults should not point at the old hub.
-            let fileIsHubDefining = ftype === "2bit" || ftype === "hub.txt";
-            let batchHasHubDefining = this.uppy.getFiles().some(f =>
-                looksLikeTwoBit(f) || looksLikeHubTxt(f));
-            // dropPath means the user dragged a folder; in that case parentDir
-            // already encodes the user's intended hub root, and redirecting to
-            // an existing assembly hub would discard the folder layout.
-            if (!drilledIntoAsmHub && !fileIsHubDefining && !batchHasHubDefining && !dropPath) {
-                let firstHub = hubCreate.firstAssemblyHub();
-                if (firstHub) {
-                    this.uppy.setFileMeta(file.id, {
-                        genome: firstHub.genome,
-                        genomeLabel: firstHub.genome,
-                        parentDir: firstHub.fileName,
-                        hubType: "assemblyHub",
-                        // NOT genomeLocked - user may want a different hub/genome
-                    });
                 }
             }
 
             // If a 2bit is in the batch, every sibling file in the same parentDir
             // adopts its genome and gets hubType=assemblyHub. Also handle hub.txt:
             // parse it client-side and, if it declares an assembly hub, mirror
             // those values onto every file (hub.txt wins).
             propagateAssemblyHubMeta(this.uppy);
 
             if (this.uppy.getFiles().length > 1) {
                 this.addBatchSelectsToDashboard();
             } else {
                 // only open the file editor when there is one file
                 const dash = uppy.getPlugin("Dashboard");
                 dash.toggleFileCard(true, file.id);