Skip to content

Commit

Permalink
Drag&drop bug (#1157)
Browse files Browse the repository at this point in the history
* Fixed issue that Drag and Droppped Files can not be deleted

* Deleted unnecessary Comment
  • Loading branch information
t71rs authored May 3, 2024
1 parent 4372536 commit fbbc71d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/resources/static/js/fileInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
5 changes: 5 additions & 0 deletions src/main/resources/static/js/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down

0 comments on commit fbbc71d

Please sign in to comment.