Skip to content

Commit

Permalink
fix(ui5-file-uploader): setting the value to an empty string also res…
Browse files Browse the repository at this point in the history
…ets the file input (#1715)
  • Loading branch information
vladitasev authored Jun 2, 2020
1 parent c1d6924 commit f8b1b39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/fiori/test/pages/uploadCollectionScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
for (var i = 0; i < files.length; i++) {
uploadCollection.appendChild(createUCI(files[i]));
}
document.getElementById("fileUploader").value = "";
});

uploadCollection.addEventListener("ui5-selectionChange", function (event) {
Expand All @@ -86,7 +87,7 @@
uploadCollection.items.forEach(function (item) {
if (item.uploadState === "Ready" && item.file) {
var oXHR = new XMLHttpRequest();

oXHR.open("POST", "/upload", true);
oXHR.onreadystatechange = function () {
if (this.status !== 200) {
Expand Down Expand Up @@ -123,4 +124,4 @@
console.log("Terminate uploading of: ", event.target);
document.getElementById("uploadStateEvent").innerText = "Terminate";
});
})()
})()
6 changes: 6 additions & 0 deletions packages/main/src/FileUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ class FileUploader extends UI5Element {
this._enableFormSupport();
}

onAfterRendering() {
if (!this.value) {
this.getDomRef().querySelector(`input[type="file"]`).value = "";
}
}

_enableFormSupport() {
const FormSupport = getFeature("FormSupport");

Expand Down

0 comments on commit f8b1b39

Please sign in to comment.