Skip to content

Commit

Permalink
Remove aria-labelledby and associated id on h2 in error summary
Browse files Browse the repository at this point in the history
In JAWS 2022, the screen reader is focusing on the error summary on load and only reading out the title because of this aria-labelledby. By removing it, we make it possible to access the content inside the error summary, communicating to screen readers why there is a problem.
  • Loading branch information
owenatgov committed Aug 15, 2022
1 parent 8b9cd65 commit d0a5dae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/govuk/components/error-summary/template.njk
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="govuk-error-summary
{%- if params.classes %} {{ params.classes }}{% endif %}" aria-labelledby="error-summary-title"
{%- if params.classes %} {{ params.classes }}{% endif %}"
{%- if params.disableAutoFocus %} data-disable-auto-focus="true"{% endif %}
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %} data-module="govuk-error-summary">
{# Keep the role="alert" in a seperate child container to prevent a race condition between
the focusing js at the alert, resulting in information getting missed in screen reader announcements #}
<div role="alert">
<h2 class="govuk-error-summary__title" id="error-summary-title">
<h2 class="govuk-error-summary__title">
{{ params.titleHtml | safe if params.titleHtml else params.titleText }}
</h2>
<div class="govuk-error-summary__body">
Expand Down
7 changes: 0 additions & 7 deletions src/govuk/components/error-summary/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ describe('Error-summary', () => {
expect(results).toHaveNoViolations()
})

it('aria-labelledby attribute matches the title id', () => {
const $ = render('error-summary', examples.default)
const ariaAttr = $('.govuk-error-summary').attr('aria-labelledby')

expect(ariaAttr).toEqual('error-summary-title')
})

it('has a child container with the role=alert attribute', () => {
const $ = render('error-summary', examples.default)
const childRoleAttr = $('.govuk-error-summary div:first-child').attr('role')
Expand Down

0 comments on commit d0a5dae

Please sign in to comment.