diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 8878e6c0d8..908f39beb4 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,4 +1,7 @@ -## RELEASE NOTES +## RELEASE NOTES-exui-4309 + +### Version 7.3.52-exui-4309 +**EXUI-4309** Error messaging when changing from an event to create case ### Version 7.3.54 **EXUI-4636** Revert CME-220 and EXUI-2111 diff --git a/package.json b/package.json index 38447a3b4c..fdeb03cdba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.3.54", + "version": "7.3.54-exui-4309", "engines": { "node": ">=20.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 6fdf4141f8..9fa6187dbd 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.3.54", + "version": "7.3.54-exui-4309", "engines": { "node": ">=20.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.spec.ts index f2e2c8e9a9..5d659e5392 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.spec.ts @@ -684,6 +684,29 @@ describe('CaseEditPageComponent - all other tests', () => { expect(comp.currentPage).toEqual(firstPage); }); + it('should clear stale validation errors on init', () => { + const staleValidationErrors = [{ id: 'field1', message: 'Stale validation error' }]; + caseEditDataService.caseFormValidationErrors$.next(staleValidationErrors); + caseEditDataService.clearFormValidationErrors.and.callFake(() => { + caseEditDataService.caseFormValidationErrors$.next([]); + }); + + comp.validationErrors = staleValidationErrors; + comp.ngOnInit(); + + expect(comp.validationErrors).toEqual([]); + expect(caseEditDataService.clearFormValidationErrors).toHaveBeenCalled(); + }); + + it('should clear validation errors when destroyed', () => { + comp.validationErrors = [{ id: 'field1', message: 'Stale validation error' }]; + + comp.ngOnDestroy(); + + expect(comp.validationErrors).toEqual([]); + expect(caseEditDataService.clearFormValidationErrors).toHaveBeenCalled(); + }); + it('should return true on hasPrevious check', () => { const errorContext = { ignoreWarning: true, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.ts index 15469dba6a..6f3f92b5d5 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.ts @@ -140,6 +140,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro public ngOnInit(): void { initDialog(); + this.clearValidationErrors(); this.eventTrigger = this.caseEdit.eventTrigger; this.editForm = this.caseEdit.form; this.wizard = this.caseEdit.wizard; @@ -197,6 +198,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro this.dialogRefAfterClosedSub?.unsubscribe(); this.saveDraftSub?.unsubscribe(); this.caseFormValidationErrorsSub?.unsubscribe(); + this.clearValidationErrors(); this.multipageComponentStateService.reset(); } @@ -225,7 +227,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro * EUI-3732 - Breathing space data not persisted on Previous button click with ExpUI Demo */ public toPreviousPage(): void { - this.caseEditDataService.clearFormValidationErrors(); + this.clearValidationErrors(); const caseEventData: CaseEventData = this.buildCaseEventData(true); caseEventData.data = caseEventData.event_data; this.updateFormData(caseEventData); @@ -393,7 +395,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro } } - this.caseEditDataService.clearFormValidationErrors(); + this.clearValidationErrors(); this.checkForStagesCompleted(); if (this.currentPageIsNotValid()) { // The generateErrorMessage method filters out the hidden fields. @@ -567,7 +569,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro this.caseEdit.cancelled.emit(); } - this.caseEditDataService.clearFormValidationErrors(); + this.clearValidationErrors(); this.multipageComponentStateService.reset(); } @@ -652,6 +654,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro } private resetErrors(): void { + this.clearValidationErrors(); this.caseEdit.error = null; this.caseEdit.ignoreWarning = false; this.triggerText = this.getTriggerText(); @@ -660,6 +663,11 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro } } + private clearValidationErrors(): void { + this.validationErrors = []; + this.caseEditDataService?.clearFormValidationErrors?.(); + } + private saveDraft() { if (this.eventTrigger.can_save_draft) { const draftCaseEventData: CaseEventData = this.formValueService.sanitise(this.editForm.value) as CaseEventData;