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

Don't override the cancel reset action when exiting

Oliver Güntherc4afc9d297c7
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.html
index 8510c44a144..c34aefb7621 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.html
+++ b/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.html
@@ -11,8 +11,8 @@
<edit-field-controls *ngIf="!(handler.inEditMode || initializationError)"
[fieldController]="field"
(onSave)="handleUserSubmit()"
- (onCancel)="handler.handleUserCancel()"
+ (onCancel)="handleUserCancel()"
[saveTitle]="text.save"
[cancelTitle]="text.cancel">
</edit-field-controls>
-</div>
\ No newline at end of file
+</div>
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.ts
index f1e2fe29753..7a52fe7067f 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/formattable-edit-field/formattable-edit-field.component.ts
@@ -57,6 +57,8 @@ export class FormattableEditFieldComponent extends EditFieldComponent implements
public previewHtml = '';
+ private cancelled = false;
+
public text:Record<string, string> = {};
public initialContent:string;
@@ -84,10 +86,12 @@ export class FormattableEditFieldComponent extends EditFieldComponent implements
ngOnDestroy():void {
super.ngOnDestroy();
- try {
- this.rawValue = this.editor?.getRawData();
- } catch (e) {
- console.error(`Failed to save CKEditor state on destroy: ${e as string}.`);
+ if (!this.cancelled) {
+ try {
+ this.rawValue = this.editor?.getRawData();
+ } catch (e) {
+ console.error(`Failed to save CKEditor state on destroy: ${e as string}.`);
+ }
}
}
@@ -122,6 +126,11 @@ export class FormattableEditFieldComponent extends EditFieldComponent implements
return false;
}
+ public handleUserCancel():void {
+ this.cancelled = true;
+ this.handler.handleUserCancel();
+ }
+
private get previewContext() {
return this.handler.previewContext(this.resource);
}