Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#46010] reset file input after selecting a file

Eric Schubert56c3cd6a397e
diff --git a/frontend/src/app/shared/components/attachments/attachments.component.ts b/frontend/src/app/shared/components/attachments/attachments.component.ts
index ff2795edd81..b191e3aaffa 100644
--- a/frontend/src/app/shared/components/attachments/attachments.component.ts
+++ b/frontend/src/app/shared/components/attachments/attachments.component.ts
@@ -198,6 +198,8 @@ export class OpAttachmentsComponent extends UntilDestroyedMixin implements OnIni
const files:UploadFile[] = Array.from(fileList);
this.uploadFiles(files);
+ // reset file input, so that selecting the same file again triggers a change
+ this.filePicker.nativeElement.value = '';
}
public onDropFiles(event:DragEvent):void {
diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.ts
index 0c0658f7e72..410fc45140a 100644
--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts
+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts
@@ -261,10 +261,12 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD
const fileList = this.filePicker.nativeElement.files;
if (fileList === null) return;
- this.openSelectLocationDialog(fileList);
+ this.openSelectLocationDialog(fileList[0]);
+ // reset file input, so that selecting the same file again triggers a change
+ this.filePicker.nativeElement.value = '';
}
- private openSelectLocationDialog(files:FileList|null):void {
+ private openSelectLocationDialog(file:File):void {
const locals = {
storageType: this.storage._links.type.href,
storageName: this.storage.name,
@@ -273,8 +275,8 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD
this.opModalService.show<LocationPickerModalComponent>(LocationPickerModalComponent, 'global', locals)
.subscribe((m) => {
m.closingEvent.subscribe((modal) => {
- if (modal.submitted && files !== null) {
- this.uploadFile(files[0], modal.location);
+ if (modal.submitted) {
+ this.uploadFile(file, modal.location);
}
});
});
@@ -483,7 +485,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD
return;
}
- this.openSelectLocationDialog(files);
+ this.openSelectLocationDialog(files[0]);
}
public onDragOver(event:DragEvent):void {