From 47319a48f9e1cfce91dbedfaccfb399afcc930bc Mon Sep 17 00:00:00 2001 From: Ritesh Dsouza Date: Thu, 14 Nov 2024 12:28:00 +0000 Subject: [PATCH] Add the fix and tests --- RELEASE-NOTES.md | 3 +++ package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- ...dynamic-radio-list-field.component.spec.ts | 25 +++++++++++++++++++ ...rite-dynamic-radio-list-field.component.ts | 4 ++- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 5c10db0ed9..ffc7fadcec 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,8 @@ ## RELEASE NOTES +### Version 7.0.77 +**EXUI-2462** DynamicRadioList incorrectly selects the wrong radio button + ### Version 7.0.75 **EXUI-2415** Redirect to an new event by a hyperlink diff --git a/package.json b/package.json index 8bb3eeb326..12501c9e56 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75", + "version": "7.0.77", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index e61648f592..e051cc816f 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.0.75", + "version": "7.0.77", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts index 95e6530a43..e19097d53f 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts @@ -98,4 +98,29 @@ describe('WriteDynamicRadioListFieldComponent', () => { expect(attr(options[1], 'id')).toEqual('MaritalStatus_F'); expect(attr(options[2], 'id')).toEqual('MaritalStatus_O'); }); + + // Note: Currently unknown why this is the default for a parent with relevant value + it('test parent value sets element ID', () => { + component.parent = {value: {id: '1', value: 'value'}} as any; + fixture.detectChanges(); + const options = de.queryAll($RADIO); + + expect(options.length).toEqual(3); + expect(attr(options[0], 'type')).toEqual('radio'); + expect(attr(options[0], 'id')).toEqual('1value'); + expect(attr(options[1], 'id')).toEqual('1value'); + expect(attr(options[2], 'id')).toEqual('1value'); + }); + + it('test parent value not present', () => { + component.parent = {value: null} as any; + fixture.detectChanges(); + const options = de.queryAll($RADIO); + + expect(options.length).toEqual(3); + expect(attr(options[0], 'type')).toEqual('radio'); + expect(attr(options[0], 'id')).toEqual('MaritalStatus_M'); + expect(attr(options[1], 'id')).toEqual('MaritalStatus_F'); + expect(attr(options[2], 'id')).toEqual('MaritalStatus_O'); + }); }); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts index add27f771b..a36f9cf641 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts @@ -33,6 +33,8 @@ export class WriteDynamicRadioListFieldComponent extends AbstractFieldWriteCompo } public createElementId(name: string): string { - return this.parent && this.parent.value ? this.parent.value.id + this.parent.value.value : super.createElementId(name); + // EXUI-2462 - parent may not always have value with content + // this is independent from the caseField.list_items so is irrelevant to event journey + return this.parent?.value?.id ? this.parent.value.id + this.parent.value.value : super.createElementId(name); } }