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:
@@ -56,9 +56,21 @@
|
||||
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;
|
||||
// Any label or descendant of a label-for=uploadInput already triggered the input
|
||||
var lbl = e.target.closest && e.target.closest('label');
|
||||
if (lbl && lbl.getAttribute('for') === uploadInput.id) return;
|
||||
if (uploadInput) uploadInput.click();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user