Skip to content

Commit f8b1b39

Browse files
authored
fix(ui5-file-uploader): setting the value to an empty string also resets the file input (#1715)
1 parent c1d6924 commit f8b1b39

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/fiori/test/pages/uploadCollectionScript.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
for (var i = 0; i < files.length; i++) {
6363
uploadCollection.appendChild(createUCI(files[i]));
6464
}
65+
document.getElementById("fileUploader").value = "";
6566
});
6667

6768
uploadCollection.addEventListener("ui5-selectionChange", function (event) {
@@ -86,7 +87,7 @@
8687
uploadCollection.items.forEach(function (item) {
8788
if (item.uploadState === "Ready" && item.file) {
8889
var oXHR = new XMLHttpRequest();
89-
90+
9091
oXHR.open("POST", "/upload", true);
9192
oXHR.onreadystatechange = function () {
9293
if (this.status !== 200) {
@@ -123,4 +124,4 @@
123124
console.log("Terminate uploading of: ", event.target);
124125
document.getElementById("uploadStateEvent").innerText = "Terminate";
125126
});
126-
})()
127+
})()

packages/main/src/FileUploader.js

+6
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ class FileUploader extends UI5Element {
247247
this._enableFormSupport();
248248
}
249249

250+
onAfterRendering() {
251+
if (!this.value) {
252+
this.getDomRef().querySelector(`input[type="file"]`).value = "";
253+
}
254+
}
255+
250256
_enableFormSupport() {
251257
const FormSupport = getFeature("FormSupport");
252258

0 commit comments

Comments
 (0)