Fix file picker reopening after selection on legal-analysis + summarize

The "browse" label's native for=input trigger AND the upload-zone click
handler both called uploadInput.click(), so the picker opened twice when
the user clicked the browse text. Stop propagation on the label and the
input itself, plus tighten the zone handler to recognise any label-for
descendant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 08:19:28 +02:00
parent 7e6463ed22
commit 5589e891f4
2 changed files with 25 additions and 2 deletions
+12 -1
View File
@@ -73,9 +73,20 @@
handleFiles(e.dataTransfer.files);
}
});
// Stop label-for and the input itself from bubbling into the zone click
// handler — otherwise the picker opens twice (native + programmatic).
var browseLabel = uploadZone.querySelector('label[for="' + (uploadInput && uploadInput.id) + '"]');
if (browseLabel) {
browseLabel.addEventListener('click', function (e) { e.stopPropagation(); });
}
if (uploadInput) {
uploadInput.addEventListener('click', function (e) { e.stopPropagation(); });
}
uploadZone.addEventListener('click', function (e) {
if (e.target === uploadClear || (uploadClear && uploadClear.contains(e.target))) return;
if (e.target.tagName === 'LABEL') return;
if (e.target === uploadInput) return;
var lbl = e.target.closest && e.target.closest('label');
if (lbl && lbl.getAttribute('for') === uploadInput.id) return;
if (uploadInput) uploadInput.click();
});
}