diff --git a/packages/main/src/FileUploader.ts b/packages/main/src/FileUploader.ts index 5f1216b2639c..bcc13f154f4e 100644 --- a/packages/main/src/FileUploader.ts +++ b/packages/main/src/FileUploader.ts @@ -304,8 +304,6 @@ class FileUploader extends UI5Element implements IFormInputElement { @property({ type: Boolean, noAttribute: true }) _tokenizerOpen = false; - static emptyInput: HTMLInputElement; - @i18n("@ui5/webcomponents") static i18nBundle: I18nBundle; @@ -488,10 +486,6 @@ class FileUploader extends UI5Element implements IFormInputElement { this._clearFileSelection(); } - _onFormSubmit(e: SubmitEvent) { - e.preventDefault(); - } - _openFileBrowser() { this._input.click(); } @@ -499,7 +493,7 @@ class FileUploader extends UI5Element implements IFormInputElement { _clearFileSelection() { this._selectedFilesNames = []; this.value = ""; - this._form?.reset(); + this._input.files = new DataTransfer().files; this.fireDecoratorEvent("change", { files: this.files, }); @@ -515,7 +509,7 @@ class FileUploader extends UI5Element implements IFormInputElement { return this._input.files; } - return FileUploader._emptyFilesList; + return null; } onAfterRendering() { @@ -621,18 +615,6 @@ class FileUploader extends UI5Element implements IFormInputElement { } } - /** - * in case when the component is not placed in the DOM, return empty FileList, like native input would do - * @private - */ - static get _emptyFilesList() { - if (!this.emptyInput) { - this.emptyInput = document.createElement("input"); - this.emptyInput.type = "file"; - } - return this.emptyInput.files; - } - get accInfo(): InputAccInfo { return { "ariaRoledescription": FileUploader.i18nBundle.getText(FILEUPLOADER_ROLE_DESCRIPTION), diff --git a/packages/main/src/FileUploaderTemplate.tsx b/packages/main/src/FileUploaderTemplate.tsx index 1150d29f0395..a7e391c620f1 100644 --- a/packages/main/src/FileUploaderTemplate.tsx +++ b/packages/main/src/FileUploaderTemplate.tsx @@ -20,7 +20,7 @@ export default function FileUploaderTemplate(this: FileUploader) { onDragOver={this._ondrag} onDrop={this._ondrop} > -