Skip to content

Commit 3668b34

Browse files
committed
Prevent ID being set on list-based components temporarily
1 parent e74061f commit 3668b34

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/server/plugins/engine/components/List.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,18 @@ describe('List', () => {
5252
it('returns list items', () => {
5353
expect(guidance).toHaveProperty('items', [
5454
{
55-
id: '52fc51fc-c75a-4b08-9c9e-6bd99b9bc49b',
5655
text: '1 day',
5756
value: 1,
5857
description:
5958
'Valid for 24 hours from the start time that you select'
6059
},
6160
{
62-
id: '56b7b34f-23b3-4446-ac8e-b2443d18588e',
6361
text: '8 day',
6462
value: 8,
6563
description:
6664
'Valid for 8 consecutive days from the start time that you select'
6765
},
6866
{
69-
id: '1af54fbc-eec2-4e1e-bd53-2415abf62677',
7067
text: '12 months',
7168
value: 365,
7269
description:

src/server/plugins/engine/components/ListFormComponent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ export class ListFormComponent extends FormComponent {
4848
listType: List['type'] = 'string'
4949

5050
get items(): Item[] {
51-
return this.list?.items ?? []
51+
return (
52+
this.list?.items.map((item) => {
53+
delete item.id // temporary workaround to prevent an ID being set, which invalidates #componentName fragments in the links
54+
return item
55+
}) ?? []
56+
)
5257
}
5358

5459
get values(): Item['value'][] {

test/form/factory.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
export function createListItemFactory(partialListItem) {
77
return {
8-
id: '52fc51fc-c75a-4b08-9c9e-6bd99b9bc49b',
98
text: 'text',
109
value: 1,
1110
description: 'Valid for 24 hours from the start time that you select',
@@ -20,7 +19,6 @@ export function createListItemFactory(partialListItem) {
2019
*/
2120
export function createListFromFactory(partialList) {
2221
return {
23-
id: '4ebe4ef5-bd3c-499b-a179-7e7e86b0dc6f',
2422
name: 'licenceLengthDays',
2523
title: 'Licence length (days)',
2624
type: 'number',

0 commit comments

Comments
 (0)