-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Breadcrumb component to improve screen reader accessibility #4995
Conversation
📋 StatsFile sizes
Modules
View stats and visualisations on the review app Action run for ca7f22d |
Rendered HTML changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-default.html b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-default.html
index 29c84d640..cbb9f21eb 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-default.html
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-default.html
@@ -1,4 +1,4 @@
-<div class="govuk-breadcrumbs">
+<nav class="govuk-breadcrumbs" aria-label="Breadcrumb">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/section">Section</a>
@@ -7,4 +7,4 @@
<a class="govuk-breadcrumbs__link" href="/section/sub-section">Sub-section</a>
</li>
</ol>
-</div>
+</nav>
diff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-inverse.html b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-inverse.html
index e52d746fc..d1879ec83 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-inverse.html
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-inverse.html
@@ -1,4 +1,4 @@
-<div class="govuk-breadcrumbs govuk-breadcrumbs--inverse">
+<nav class="govuk-breadcrumbs govuk-breadcrumbs--inverse" aria-label="Breadcrumb">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/">Home</a>
@@ -8,4 +8,4 @@
</li>
<li class="govuk-breadcrumbs__list-item" aria-current="page">Travel abroad</li>
</ol>
-</div>
+</nav>
diff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-collapse-on-mobile.html b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-collapse-on-mobile.html
index 448a220dd..1b4af87b9 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-collapse-on-mobile.html
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-collapse-on-mobile.html
@@ -1,4 +1,4 @@
-<div class="govuk-breadcrumbs govuk-breadcrumbs--collapse-on-mobile">
+<nav class="govuk-breadcrumbs govuk-breadcrumbs--collapse-on-mobile" aria-label="Breadcrumb">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/">Home</a>
@@ -10,4 +10,4 @@
<a class="govuk-breadcrumbs__link" href="/education/special-educational-needs-and-disability-send-and-high-needs">Special educational needs and disability (SEND) and high needs</a>
</li>
</ol>
-</div>
+</nav>
diff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-last-breadcrumb-as-current-page.html b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-last-breadcrumb-as-current-page.html
index 263824e47..af6bcc1ba 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-last-breadcrumb-as-current-page.html
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-last-breadcrumb-as-current-page.html
@@ -1,4 +1,4 @@
-<div class="govuk-breadcrumbs">
+<nav class="govuk-breadcrumbs" aria-label="Breadcrumb">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/">Home</a>
@@ -8,4 +8,4 @@
</li>
<li class="govuk-breadcrumbs__list-item" aria-current="page">Travel abroad</li>
</ol>
-</div>
+</nav>
diff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-multiple-levels.html b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-multiple-levels.html
index 9b87afae1..f9cf0ba36 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-multiple-levels.html
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-multiple-levels.html
@@ -1,4 +1,4 @@
-<div class="govuk-breadcrumbs">
+<nav class="govuk-breadcrumbs" aria-label="Breadcrumb">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/">Home</a>
@@ -13,4 +13,4 @@
<a class="govuk-breadcrumbs__link" href="/section/sub-section/sub-sub-section">Sub Sub-section</a>
</li>
</ol>
-</div>
+</nav>
diff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-one-level.html b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-one-level.html
index 8617ab748..50085fd4f 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-one-level.html
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-one-level.html
@@ -1,7 +1,7 @@
-<div class="govuk-breadcrumbs">
+<nav class="govuk-breadcrumbs" aria-label="Breadcrumb">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/section">Section</a>
</li>
</ol>
-</div>
+</nav>
diff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-without-the-home-section.html b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-without-the-home-section.html
index b61e4eb65..39d3bc377 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-without-the-home-section.html
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/template-without-the-home-section.html
@@ -1,4 +1,4 @@
-<div class="govuk-breadcrumbs">
+<nav class="govuk-breadcrumbs" aria-label="Breadcrumb">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="/service-manual">Service Manual</a>
@@ -7,4 +7,4 @@
<a class="govuk-breadcrumbs__link" href="/service-manual/agile-delivery">Agile Delivery</a>
</li>
</ol>
-</div>
+</nav>
Action run for ca7f22d |
Other changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/fixtures.json b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/fixtures.json
index 56f6393af..5da6f0a52 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/fixtures.json
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/fixtures.json
@@ -19,7 +19,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\">Section</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section/sub-section\">Sub-section</a>\n </li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\">Section</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section/sub-section\">Sub-section</a>\n </li>\n </ol>\n</nav>"
},
{
"name": "with one level",
@@ -35,7 +35,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\">Section</a>\n </li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\">Section</a>\n </li>\n </ol>\n</nav>"
},
{
"name": "with multiple levels",
@@ -63,7 +63,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\">Section</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section/sub-section\">Sub-section</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section/sub-section/sub-sub-section\">Sub Sub-section</a>\n </li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\">Section</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section/sub-section\">Sub-section</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section/sub-section/sub-sub-section\">Sub Sub-section</a>\n </li>\n </ol>\n</nav>"
},
{
"name": "without the home section",
@@ -83,7 +83,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/service-manual\">Service Manual</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/service-manual/agile-delivery\">Agile Delivery</a>\n </li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/service-manual\">Service Manual</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/service-manual/agile-delivery\">Agile Delivery</a>\n </li>\n </ol>\n</nav>"
},
{
"name": "with last breadcrumb as current page",
@@ -106,7 +106,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/browse/abroad\">Passports, travel and living abroad</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Travel abroad</li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/browse/abroad\">Passports, travel and living abroad</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Travel abroad</li>\n </ol>\n</nav>"
},
{
"name": "with collapse on mobile",
@@ -131,7 +131,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs govuk-breadcrumbs--collapse-on-mobile\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/education\">Education, training and skills</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/education/special-educational-needs-and-disability-send-and-high-needs\">Special educational needs and disability (SEND) and high needs</a>\n </li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs govuk-breadcrumbs--collapse-on-mobile\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/education\">Education, training and skills</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/education/special-educational-needs-and-disability-send-and-high-needs\">Special educational needs and disability (SEND) and high needs</a>\n </li>\n </ol>\n</nav>"
},
{
"name": "inverse",
@@ -157,7 +157,7 @@
"inverse"
],
"screenshot": true,
- "html": "<div class=\"govuk-breadcrumbs govuk-breadcrumbs--inverse\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/browse/abroad\">Passports, travel and living abroad</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Travel abroad</li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs govuk-breadcrumbs--inverse\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Home</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/browse/abroad\">Passports, travel and living abroad</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Travel abroad</li>\n </ol>\n</nav>"
},
{
"name": "classes",
@@ -173,14 +173,14 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs app-breadcrumbs--custom-modifier\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Home</li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs app-breadcrumbs--custom-modifier\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Home</li>\n </ol>\n</nav>"
},
{
"name": "attributes",
"options": {
"attributes": {
"id": "my-navigation",
- "role": "navigation"
+ "data-foo": "bar"
},
"items": [
{
@@ -192,7 +192,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\" id=\"my-navigation\" role=\"navigation\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Home</li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" id=\"my-navigation\" data-foo=\"bar\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\">Home</li>\n </ol>\n</nav>"
},
{
"name": "item attributes",
@@ -212,7 +212,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\" data-attribute=\"my-attribute\" data-attribute-2=\"my-attribute-2\">Section 1</a>\n </li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section\" data-attribute=\"my-attribute\" data-attribute-2=\"my-attribute-2\">Section 1</a>\n </li>\n </ol>\n</nav>"
},
{
"name": "html as text",
@@ -231,7 +231,7 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section-1\"><span>Section 1</span></a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\"><span>Section 2</span></li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section-1\"><span>Section 1</span></a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\"><span>Section 2</span></li>\n </ol>\n</nav>"
},
{
"name": "html",
@@ -242,7 +242,8 @@
"href": "/section-1"
},
{
- "html": "<em>Section 2</em>"
+ "html": "<em>Section 2</em>",
+ "href": "/section-2"
}
]
},
@@ -250,7 +251,28 @@
"description": "",
"previewLayoutModifiers": [],
"screenshot": false,
- "html": "<div class=\"govuk-breadcrumbs\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section-1\"><em>Section 1</em></a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\" aria-current=\"page\"><em>Section 2</em></li>\n </ol>\n</div>"
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Breadcrumb\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section-1\"><em>Section 1</em></a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/section-2\"><em>Section 2</em></a>\n </li>\n </ol>\n</nav>"
+ },
+ {
+ "name": "custom label",
+ "options": {
+ "labelText": "Briwsion bara",
+ "items": [
+ {
+ "text": "Hafan",
+ "href": "/"
+ },
+ {
+ "text": "Sefydliadau",
+ "href": "/organisations"
+ }
+ ]
+ },
+ "hidden": true,
+ "description": "",
+ "previewLayoutModifiers": [],
+ "screenshot": false,
+ "html": "<nav class=\"govuk-breadcrumbs\" aria-label=\"Briwsion bara\">\n <ol class=\"govuk-breadcrumbs__list\">\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/\">Hafan</a>\n </li>\n <li class=\"govuk-breadcrumbs__list-item\">\n <a class=\"govuk-breadcrumbs__link\" href=\"/organisations\">Sefydliadau</a>\n </li>\n </ol>\n</nav>"
}
]
}
diff --git a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/macro-options.json b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/macro-options.json
index 801134d8e..4ac5d1d24 100644
--- a/packages/govuk-frontend/dist/govuk/components/breadcrumbs/macro-options.json
+++ b/packages/govuk-frontend/dist/govuk/components/breadcrumbs/macro-options.json
@@ -48,5 +48,11 @@
"type": "object",
"required": false,
"description": "HTML attributes (for example data attributes) to add to the breadcrumbs container."
+ },
+ {
+ "name": "labelText",
+ "type": "string",
+ "required": false,
+ "description": "Plain text label identifying the landmark to screen readers. Defaults to \"Breadcrumb\"."
}
]
Action run for ca7f22d |
f24cf4c
to
6d8b711
Compare
6d8b711
to
74532cc
Compare
I generally agree with Tom's initial assessment back in 2013 that there were way too many navigation landmarks on the page. Although they had worked on removing some, I assume some have moved back in or were added later as www.gov.uk still uses way too many, lots of which should perhaps be removed. (For example, tax codes has 6 navigation landmarks, at least half of which are probably not necessary.)
That is a very good point. A point that makes me think maybe this is a good idea. Something that is a bit problematic is that when breadcrumbs are used on www.gov.uk, they are often not very useful as the website's hierarchy is presented as pretty flat. Therefore the breadcrumbs often only have a "Home" link and then a link to the page's general topic. Overall I'm happy with this change. The only thing I would like to get input from a content designer for is the label "Breadcrumb". |
Also, directly related to #4451. |
Thanks @selfthinker. I think I've got all the context. I’m not sure I can do better than W3C’s example that just calls it “Breadcrumbs” Something like "You are here" is tricky because 'here' could be easily misinterpreted to mean any of the breadcrumb links. If anything, there's the idea of "Page levels" or "Page levels for this page", but that's only slightly less jargon-y but also imprecise as it might be mistaken for something concerning the page itself and overemphasise its importance. |
@calvin-lau-sig7, I've tried to google alternative names and also if there has been any research about the name with screen reader users but couldn't find anything for the latter and only very little for the former. |
Thanks for the investigtion @selfthinker! Continuing our musings, something like "Page level path" could be a bit more descriptive, as long as it's not mistaken for the user's back history. I might need to better understand the semantics for "You are here"... would the ARIA tag be understood to refer to the whole list, without too much risk of being mistaken for one of the links in the list? |
We had similar thoughts when we introduced the pagination component and how we should accessibly label that. In that instance, we stuck with 'pagination' because, even though it's probably more niche terminology than necessary, it was the labelling that the overwhelming amount of other examples we could find also used for their accessible labels, so it seemed likely that assistive technology users would have encountered it many times before and probably understood what it referred to. That's just anec-data though, and we didn't specifically test that assumption. |
Yes, it would refer to the whole list, or rather to the navigation landmark the list is in. That can be discovered by navigating by landmark or arrowing through the page. It would then announce something like "Breadcrumb, navigation" before it gets into the list, so clearly not a link. |
Just clarifying... It would read "[whatever the aria-label says], navigation", so "You are here, navigation" in the other case. (And some screen readers also add "region" or "landmark" at the end.) |
The way that Breadcrumbs is currently often used has it only list the ancestors of the current page, but omits the current page (as that is given by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component code looks good, as do the tests 🙌🏻 However, we've updated the breadcrumbs tests to use JSDOM in #5027 (sorry for not thinking of this PR while reviewing it), so the tests will need a little update before we can merge 😊
b4d5be0
to
48cc77c
Compare
@romaricpascal I've rebased from main and updated the new tests to use JSDOM 🎉 |
48cc77c
to
ca7f22d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've rebased from main and updated the new tests to use JSDOM 🎉
Ace! Thanks for rebasing. All good to go (code-wise, that is) ⛵
Okay, @querkmachine's point here is a strong one – breadcrumb content often does not actually indicate the current page, instead only showing the earlier or higher-level pages. Based on this I'd agree we should keep it to "Breadcrumb", as we can't rely on the breadcrumb being a reliable indication of "here". I'm open to figuring out a more plain English label amongst us that'd work through. E.g. How you got here (if that were accurate). |
I'm going to merge this given it's had approval and the consensus seems to be that current default labelling is sensible, even if not ideal. We can still update it later in the cycle without issue. |
Update Breadcrumb component to improve screen reader accessibility
An accessibility issue raised during development of #4950 was that, when a Breadcrumbs component is placed following a Header or Service Header that contains navigation elements, they are both announced (by screen readers) or displayed (in no CSS/reader modes) as a bulleted lists of links, with little affordance to users that they are two distinct navigational elements.
This PR aims to resolve the screen reader issue by adding an
aria-label
of "Breadcrumb". It does not solve the display issue. Doing so would require the inclusion of some visible or visually-hidden text, judging by @selfthinker's comment on the GOV.UK Publishing Components version: alphagov/govuk_publishing_components#2045 (comment), though we could choose to modify this PR to do that as well.As
aria-label
is only supported in practice by interactive elements and landmarks, the breadcrumb component wrapper has been changed to anav
to make it a landmark element. Doing so also resolves a common accessibility audit complaint that this component does not exist within a landmark (e.g. #1604). This is not strictly required to meet WCAG, but may be considered good practice.Background
The breadcrumb navigation was previously contained within a
nav
element, but this was removed in 2013 in an effort to reduce the number of navigation landmarks that appear on the page, as documented in this blog post by @tombye.However, I think that the Breadcrumbs do not meet the criteria for removing
nav
as given in the post—the individual links do not provide sufficient labelling on their own and the components' role as a navigational aid can only be inferred through visual context which is not available to users who are blind or with low vision, nor assistive technologies they may use, and for which no fallback is provided.Compare Breadcrumbs with other
nav
elements it's common to find on GOV.UK:header
(banner
) landmark and near the top of the page.footer
(contentinfo
) landmark.nav
elements that appear on GOV.UK have visible headings (e.g. related content lists), accessible labels (e.g. pagination), or can have some context inferred from their parents (e.g. table of contents has acomplementary
role and is one of the first things inside of themain
landmark). Most provide multiple of these affordances.Breadcrumbs currently have none of these: they lack the
nav
element, they lack headings (visible or not), lack accessible labelling, their context cannot be inferred from a parent landmark because they don't have one, and it cannot be inferred from the links themselves as (apart from 'Home') they are disembodied section names.With these changes, our component is much more in line with the example in the WAI ARIA Authoring Guide and the W3C's design system component (which is heavily inspired by ours, their deviation implying they felt we were in the wrong here). The same approach is also used by our friends at ONS, Scottish Government Design System and USWDS, really putting us in the minority with our current approach.
Changes
div
to anav
.aria-label
to the Breadcrumb component wrapper.aria-label
namedlabelText
. This defaults to"Breadcrumb"
.labelText
.nav
, renders the defaultaria-label
, and that the Nunjucks parameter can override thearia-label
.role="navigation"
, as this was being flagged by the HTML linter as redundant role usage.