Fix file dialog double-open: add stopPropagation and reset input value
This commit is contained in:
parent
5e62b3d308
commit
6f727b1f3d
@ -73,17 +73,26 @@ class TranscriptionApp {
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
const browseLink = document.querySelector('.browse-link');
|
||||
|
||||
// Click to browse
|
||||
browseLink.addEventListener('click', () => fileInput.click());
|
||||
dropZone.addEventListener('click', (e) => {
|
||||
if (e.target === dropZone || e.target.closest('.drop-zone-content')) {
|
||||
// Click on browse link (stop propagation to avoid double click)
|
||||
browseLink.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
fileInput.click();
|
||||
}
|
||||
});
|
||||
|
||||
// File input change
|
||||
// Click on drop zone (but not on the file input itself)
|
||||
dropZone.addEventListener('click', (e) => {
|
||||
if (e.target === fileInput) return;
|
||||
fileInput.click();
|
||||
});
|
||||
|
||||
// File input change - reset value after handling
|
||||
fileInput.addEventListener('change', (e) => {
|
||||
this.handleFiles(e.target.files);
|
||||
const files = e.target.files;
|
||||
if (files.length) {
|
||||
this.handleFiles(files);
|
||||
}
|
||||
// Reset so the same file can be selected again
|
||||
fileInput.value = '';
|
||||
});
|
||||
|
||||
// Drag & drop
|
||||
|
||||
Loading…
Reference in New Issue
Block a user