From d460d6525e27cb1f1e5408b9290f3478a486340f Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 1 May 2026 10:22:14 +0100 Subject: [PATCH 1/3] Clear stale case edit validation errors --- .../case-edit-page/case-edit-page.component.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 915e2485ac..ffcdb06a41 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. @@ -563,7 +565,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro this.caseEdit.cancelled.emit(); } - this.caseEditDataService.clearFormValidationErrors(); + this.clearValidationErrors(); this.multipageComponentStateService.reset(); } @@ -648,6 +650,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(); @@ -656,6 +659,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; From d3af47472d55ecdc7d3fa58b872c135a5bee0418 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 1 May 2026 10:22:44 +0100 Subject: [PATCH 2/3] added unit tests --- .../case-edit-page.component.spec.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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 3f93803567..78d2063ffd 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 @@ -651,6 +651,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, From 2de54162c605f71a61dcf2f045faf4caf1b2b2f5 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 1 May 2026 10:24:38 +0100 Subject: [PATCH 3/3] updated toolkit version --- RELEASE-NOTES.md | 5 ++++- package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 0c4ee17666..9d2da3f291 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.52 **EXUI-4311** Remove unused packages diff --git a/package.json b/package.json index 8b22fa4242..ae0e30f7a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.3.52", + "version": "7.3.52-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 f56593eb73..d7063d8adc 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.52", + "version": "7.3.52-exui-4309", "engines": { "node": ">=20.19.0" },