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

fix adding attachment after deleting one

ulferts87e0592a4a84
diff --git a/frontend/src/app/modules/attachments/attachment-list/attachment-list.component.ts b/frontend/src/app/modules/attachments/attachment-list/attachment-list.component.ts
index f8aae367b90..2781e4318a4 100644
--- a/frontend/src/app/modules/attachments/attachment-list/attachment-list.component.ts
+++ b/frontend/src/app/modules/attachments/attachment-list/attachment-list.component.ts
@@ -100,7 +100,13 @@ export class AttachmentListComponent implements OnInit, OnChanges, OnDestroy {
public removeAttachment(attachment:HalResource) {
this.deletedAttachments.push(attachment);
- this.attachments = this.attachments.filter((el) => el !== attachment);
+ // Keep the same object as we would otherwise loose the connection to the
+ // resource's attachments array. That way, attachments added after removing one would not be displayed.
+ // This is bad design.
+ let newAttachments = this.attachments.filter((el) => el !== attachment);
+ this.attachments.length = 0;
+ this.attachments.push(...newAttachments);
+
this.cdRef.detectChanges();
}