You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm expecting that this library produce output markup that mirrors the design system reference markup.
It looks like hints and error messages are not associated correctly with fieldsets - and thus all items that use fieldset like radios and checkboxes. This is likely an accessibility issue - both that it's not following the reference implementation that's been tested hundreds of times, but also that errors aren't associated at all - and a screen reader user might not get it.
For a set of radios like this:
The reference design system markup is:
<divclass="nhsuk-form-group nhsuk-form-group--error"><fieldsetclass="nhsuk-fieldset" aria-describedby="example-error-hint example-error-error"><legendclass="nhsuk-fieldset__legend">
Have you changed your name?
</legend><divclass="nhsuk-hint" id="example-error-hint">
This includes changing your last name or spelling your name differently.
</div><spanclass="nhsuk-error-message" id="example-error-error"><spanclass="nhsuk-u-visually-hidden">Error:</span> Select yes if you have changed your name
</span><divclass="nhsuk-radios"><divclass="nhsuk-radios__item"><inputclass="nhsuk-radios__input" id="example-error-1" name="example-error" type="radio" value="yes"><labelclass="nhsuk-label nhsuk-radios__label" for="example-error-1">
Yes
</label></div><divclass="nhsuk-radios__item"><inputclass="nhsuk-radios__input" id="example-error-2" name="example-error" type="radio" value="no"><labelclass="nhsuk-label nhsuk-radios__label" for="example-error-2">
No
</label></div></div></fieldset></div>
The markup in story book is:
<divclass="nhsuk-form-group nhsuk-form-group--error"><fieldsetclass="nhsuk-fieldset"><legendclass="nhsuk-fieldset__legend">Have you changed your name?</legend><divclass="nhsuk-form-group nhsuk-form-group--error"><divclass="nhsuk-hint" id="radios_7l6kx--hint">This includes changing your last name or spelling your name differently.</div><spanclass="nhsuk-error-message" id="radios_7l6kx--error-message" role="alert"><spanclass="nhsuk-u-visually-hidden">Error: </span>Please select an option
</span><divclass="nhsuk-radios" id="radios_7l6kx" aria-describedby="radios_7l6kx--hint"><divclass="nhsuk-radios__item"><inputclass="nhsuk-radios__input" id="example-1" name="example" aria-labelledby="example-1--label" type="radio" value="yes"><labelclass="nhsuk-label nhsuk-radios__label" id="example-1--label" for="example-1">Yes</label></div><divclass="nhsuk-radios__item"><inputclass="nhsuk-radios__input" id="example-2" name="example" aria-labelledby="example-2--label" type="radio" value="no" checked=""><labelclass="nhsuk-label nhsuk-radios__label" id="example-2--label" for="example-2">No</label></div></div></div></fieldset></div>
Issues:
The hint is not associated with the fieldset (though it is incorrectly associated with a div wrapping the two inputs)
The error message is not associated with anything
The text was updated successfully, but these errors were encountered:
Thinking about this some more, I suspect it's because the radios and checkboxes components don't contain the fieldset or legend components - the examples in the storybook have you use those components separately and then nest the checkboses or radios.
This is a risky approach as it would require end users to manually add the appropriate aria descriptions to fieldsets - developers shouldn't need to worry about this - the component should aim to take care of all markup, given appropriate inputs.
The way the NHS and GOV.UK design system components handle this is to make fieldset an optional argument to the radio and checkboxes components - if provided, the component wraps itself in the fieldset component and applies the appropriate aria descriptions.
NHS design system native component:
{{ radios({
"idPrefix": "example-error",
"name": "example-error",
"errorMessage": {
"text": "Select yes if you have changed your name"
},
"fieldset": {
"legend": {
"text": "Have you changed your name?",
"classes": "nhsuk-fieldset__legend--l",
"isPageHeading": true
}
},
"hint": {
"text": "This includes changing your last name or spelling your name differently."
},
"items": [
{
"value": "yes",
"text": "Yes"
},
{
"value": "no",
"text": "No"
}
]
}) }}
Here you can see that fieldset is an optional property of radios and checkboxes, and legend is a property of fieldset. I think this this library's radio and checkbox components could be extended to accept these optional properties.
I'm expecting that this library produce output markup that mirrors the design system reference markup.
It looks like hints and error messages are not associated correctly with fieldsets - and thus all items that use fieldset like radios and checkboxes. This is likely an accessibility issue - both that it's not following the reference implementation that's been tested hundreds of times, but also that errors aren't associated at all - and a screen reader user might not get it.
For a set of radios like this:
The reference design system markup is:
The markup in story book is:
Issues:
The text was updated successfully, but these errors were encountered: