diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ef9af36b3..4191ddba4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -63,6 +63,21 @@ Do not include an empty ` ` with
This change was introduced in [pull request #2323: Avoid invalid nesting of `` within a `` in summary list](https://github.com/alphagov/govuk-frontend/pull/2323).
+#### Update the HTML for navigation in the header
+
+We've updated the HTML for the header. This update only affects you if your header includes navigation.
+
+Any additional classes passed using the `navigationClasses` Nunjucks option are now applied to the `` rather than the ``. Check that the additional classes are still doing what you expect.
+
+If you're not using Nunjucks macros, then you should move:
+
+- the `` inside the ``, immediately before the ``
+- the `aria-label` from the `` to the ``
+
+Check your changes against the [header example in the Design System](https://design-system.service.gov.uk/components/header/#header-with-service-name-and-navigation).
+
+This change was introduced in [pull request #2427: Improve the screen reader experience for the header menu](https://github.com/alphagov/govuk-frontend/pull/2427).
+
#### Make sure components that conditionally reveal other questions still work as expected
On radios and checkboxes, the JavaScript now looks within the whole page for conditionally revealed content. Before, it only looked within the same set of radios or checkboxes.
diff --git a/src/govuk/components/header/_index.scss b/src/govuk/components/header/_index.scss
index 67ac75469b..9f0c241747 100644
--- a/src/govuk/components/header/_index.scss
+++ b/src/govuk/components/header/_index.scss
@@ -206,16 +206,18 @@
}
.govuk-header__navigation {
- display: block;
- margin: 0;
- padding: 0;
- list-style: none;
-
@include govuk-media-query ($from: desktop) {
margin-bottom: govuk-spacing(2);
}
}
+ .govuk-header__navigation-list {
+ // Reset user-agent default list styles
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ }
+
.js-enabled {
.govuk-header__menu-button {
display: block;
@@ -224,14 +226,14 @@
}
}
- .govuk-header__navigation {
+ .govuk-header__navigation-list {
display: none;
@include govuk-media-query ($from: desktop) {
display: block;
}
}
- .govuk-header__navigation--open {
+ .govuk-header__navigation-list--open {
display: block;
}
}
diff --git a/src/govuk/components/header/header.js b/src/govuk/components/header/header.js
index ca2151941d..cf92b3908f 100644
--- a/src/govuk/components/header/header.js
+++ b/src/govuk/components/header/header.js
@@ -21,7 +21,7 @@ Header.prototype.init = function () {
return
}
- this.syncState(this.$menu.classList.contains('govuk-header__navigation--open'))
+ this.syncState(this.$menu.classList.contains('govuk-header__navigation-list--open'))
this.$menuButton.addEventListener('click', this.handleMenuButtonClick.bind(this))
}
@@ -45,7 +45,7 @@ Header.prototype.syncState = function (isVisible) {
* sync the accessibility state and menu button state
*/
Header.prototype.handleMenuButtonClick = function () {
- var isVisible = this.$menu.classList.toggle('govuk-header__navigation--open')
+ var isVisible = this.$menu.classList.toggle('govuk-header__navigation-list--open')
this.syncState(isVisible)
}
diff --git a/src/govuk/components/header/header.test.js b/src/govuk/components/header/header.test.js
index 267154bf00..6a546a205f 100644
--- a/src/govuk/components/header/header.test.js
+++ b/src/govuk/components/header/header.test.js
@@ -68,8 +68,8 @@ describe('Header navigation', () => {
})
it('adds the --open modifier class to the menu, making it visible', async () => {
- const hasOpenClass = await page.$eval('.govuk-header__navigation',
- el => el.classList.contains('govuk-header__navigation--open')
+ const hasOpenClass = await page.$eval('.govuk-header__navigation-list',
+ el => el.classList.contains('govuk-header__navigation-list--open')
)
expect(hasOpenClass).toBeTruthy()
@@ -102,8 +102,8 @@ describe('Header navigation', () => {
})
it('removes the --open modifier class from the menu, hiding it', async () => {
- const hasOpenClass = await page.$eval('.govuk-header__navigation',
- el => el.classList.contains('govuk-header__navigation--open')
+ const hasOpenClass = await page.$eval('.govuk-header__navigation-list',
+ el => el.classList.contains('govuk-header__navigation-list--open')
)
expect(hasOpenClass).toBeFalsy()
diff --git a/src/govuk/components/header/template.njk b/src/govuk/components/header/template.njk
index b54d9cc423..96dbed671a 100644
--- a/src/govuk/components/header/template.njk
+++ b/src/govuk/components/header/template.njk
@@ -54,9 +54,10 @@
{% endif %}
{% if params.navigation %}
-
-
-