Drag&drop bug (#1157)

* Fixed issue that Drag and Droppped Files can not be deleted

* Deleted unnecessary Comment
This commit is contained in:
t71rs 2024-05-03 20:09:36 +02:00 committed by GitHub
parent 4372536c17
commit fbbc71d7e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -104,4 +104,9 @@ function setupFileInput(chooser) {
$(inputElement).siblings(".custom-file-label").addClass("selected").html(pdfPrompt);
}
}
//Listen for event of file being removed and the filter it out of the allFiles array
document.addEventListener("fileRemoved", function (e) {
const fileName = e.detail;
allFiles = allFiles.filter(file => file.name !== fileName);
});
}

View File

@ -69,8 +69,13 @@ function attachMoveButtons() {
removeButtons[i].addEventListener("click", function (event) {
event.preventDefault();
var parent = this.closest(".list-group-item");
//Get name of removed file
var fileName = parent.querySelector(".filename").innerText;
parent.remove();
updateFiles();
//Dispatch a custom event with the name of the removed file
var event = new CustomEvent("fileRemoved", { detail: fileName });
document.dispatchEvent(event);
});
}
}