diff --git a/src/Squidex/app/framework/angular/forms/control-errors.component.ts b/src/Squidex/app/framework/angular/forms/control-errors.component.ts index 010e2777e..d58093df1 100644 --- a/src/Squidex/app/framework/angular/forms/control-errors.component.ts +++ b/src/Squidex/app/framework/angular/forms/control-errors.component.ts @@ -60,10 +60,7 @@ export class ControlErrorsComponent extends StatefulComponent implements public ngOnDestroy() { super.ngOnDestroy(); - - if (this.control && this.originalMarkAsTouched) { - this.control['markAsTouched'] = this.originalMarkAsTouched; - } + this.restoreOriginalMarkAsTouchedFunction(); } public ngOnChanges() { @@ -87,6 +84,7 @@ export class ControlErrorsComponent extends StatefulComponent implements if (this.control !== control) { this.unsubscribeAll(); + this.restoreOriginalMarkAsTouchedFunction(); this.control = control; @@ -112,6 +110,12 @@ export class ControlErrorsComponent extends StatefulComponent implements this.createMessages(); } + private restoreOriginalMarkAsTouchedFunction() { + if (this.control && this.originalMarkAsTouched) { + this.control['markAsTouched'] = this.originalMarkAsTouched; + } + } + private createMessages() { const errors: string[] = []; @@ -131,4 +135,4 @@ export class ControlErrorsComponent extends StatefulComponent implements this.next(s => ({ ...s, errorMessages: errors })); } } -} \ No newline at end of file +}