alphagov / govuk_publishing_components

A gem to document and distribute frontend components for GOV.UK applications
https://components.publishing.service.gov.uk
MIT License
66 stars 20 forks source link

Wrong heading order when attachments are used #3561

Open selfthinker opened 1 year ago

selfthinker commented 1 year ago

What

When Whitehall block attachments or the attachment component are used, it can happen that the heading order on the page is wrong because the heading level for attachments is hard-coded.

Example URLs where the context makes the heading level wrong:

Publications used to be fine because they included a "Documents" h2 before the attachments' h3s. See this publication, for example. But that was changed at some point and now the same page has the same issue because the attachments' headings have changed to an H2.

Why

A correct heading hierarchy helps screen reader users understand the structure and relationship of content on a page.

More context

This was found in the 2022 WCAG audit of GOV.UK. It's an accessibility issue but not a WCAG fail. This issue is not entirely due to the publishing components as some of the markup is coming from Whitehall.

ollietreend commented 1 year ago

Publication pages are always fine because they include a "Documents" h2 before the attachments' h3s. For example, https://www.gov.uk/government/statistics/learning-disability-services-monthly-statistics-commissioner-census-assuring-transformation-august-2015

@selfthinker I think this actually does affect publication pages too.

Looking at the example link you shared, the "Documents" heading is a H2 but so is the attachment title. They're both H2s rather than a H2 and a H3.

Screenshot of HTML structure from the example page
selfthinker commented 1 year ago

Looking at the example link you shared, the "Documents" heading is a H2 but so is the attachment title. They're both H2s rather than a H2 and a H3.

Interesting. That has changed since we wrote the original ticket (which was back in October 2022). Back then the heading for the document was an H3. Here is a version from October 2022.

So, yes, you're right. I'll amend the description accordingly.