diff --git a/src/app/carbon-estimator-form/carbon-estimator-form.component.ts b/src/app/carbon-estimator-form/carbon-estimator-form.component.ts index fb9f298..f3cc7e9 100644 --- a/src/app/carbon-estimator-form/carbon-estimator-form.component.ts +++ b/src/app/carbon-estimator-form/carbon-estimator-form.component.ts @@ -171,8 +171,7 @@ export class CarbonEstimatorFormComponent implements OnInit { this.errorSummary?.summary.nativeElement.focus(); return; } - this.validationErrors = []; - this.showErrorSummary = false; + this.resetValidationErrors(); const formValue = this.estimatorForm.getRawValue(); if (formValue.onPremise.serverLocation === 'unknown') { formValue.onPremise.serverLocation = 'WORLD'; @@ -188,8 +187,7 @@ export class CarbonEstimatorFormComponent implements OnInit { public resetForm() { this.estimatorForm.reset(); - this.validationErrors = []; - this.showErrorSummary = false; + this.resetValidationErrors(); this.formReset.emit(); } @@ -227,4 +225,9 @@ export class CarbonEstimatorFormComponent implements OnInit { return validationErrors; } + + private resetValidationErrors() { + this.validationErrors = []; + this.showErrorSummary = false; + } }