Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 5 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@defra/forms-model": "^3.0.674",
"@defra/forms-model": "^3.0.677",
"@defra/hapi-tracing": "^1.29.0",
"@defra/interactive-map": "^0.0.22-alpha",
"@elastic/ecs-pino-format": "^1.5.0",
Expand Down
18 changes: 14 additions & 4 deletions src/server/plugins/engine/components/FormComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ export class FormComponent extends ComponentBase {

this.type = type
this.hint = hint
this.label =
'shortDescription' in def && def.shortDescription
? def.shortDescription
: def.title

this.label = this.getLabel(def)
}

getLabel(def: FormComponentsDef) {
if ('errorDescription' in def && def.errorDescription) {
return def.errorDescription
}

if ('shortDescription' in def && def.shortDescription) {
return def.shortDescription
}

return def.title
}

get keys() {
Expand Down
28 changes: 27 additions & 1 deletion src/server/plugins/engine/components/TextField.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,33 @@ describe('TextField', () => {
describe('Validation', () => {
describe.each([
{
description: 'Use short description if it exists',
description: 'Use error description if it exists',
component: {
title: 'What is your example text?',
errorDescription: 'Example text',
shortDescription: 'Your example text',
name: 'myComponent',
type: ComponentType.TextField,
options: {},
schema: {}
} satisfies TextFieldComponent,
assertions: [
{
input: getFormData(''),
output: {
value: getFormData(''),
errors: [
expect.objectContaining({
text: 'Enter example text'
})
]
}
}
]
},
{
description:
'Use short description if it exists and error description does not',
component: {
title: 'What is your example text?',
shortDescription: 'Your example text',
Expand Down
Loading
Loading