Skip to content

Commit 0ed181d

Browse files
authored
Merge pull request #3791 from alphagov/kg-mobile-button-toggle-text
Refactor mobile menu button label/text handling
2 parents da5aaac + 0cc8f78 commit 0ed181d

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

src/govuk/components/header/header.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ params:
5555
- name: menuButtonLabel
5656
type: string
5757
required: false
58-
description: Text for the `aria-label` attribute of the button that opens the mobile navigation, if there is a mobile navigation menu. Defaults to 'Show or hide menu'.
58+
description: Text for the `aria-label` attribute of the button that opens the mobile navigation, if there is a mobile navigation menu.
5959
- name: menuButtonText
6060
type: string
6161
required: false

src/govuk/components/header/template.njk

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
{% endif %}
5959
{% if params.navigation %}
6060
<nav aria-label="{{ params.navigationLabel | default(menuButtonText) }}" class="govuk-header__navigation {{ params.navigationClasses if params.navigationClasses }}">
61-
<button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="{{ params.menuButtonLabel | default('Show or hide menu') }}" hidden>{{ menuButtonText }}</button>
61+
<button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation"{%- if params.menuButtonLabel and params.menuButtonLabel != menuButtonText %} aria-label="{{ params.menuButtonLabel }}"{% endif %} hidden>{{ menuButtonText }}</button>
6262

6363
<ul id="navigation" class="govuk-header__navigation-list">
6464
{% for item in params.navigation %}

src/govuk/components/header/template.test.js

-7
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,6 @@ describe('header', () => {
207207

208208
expect($button.attr('hidden')).toBeTruthy()
209209
})
210-
it('renders default label correctly', () => {
211-
const $ = render('header', examples['with navigation'])
212-
213-
const $button = $('.govuk-header__menu-button')
214-
215-
expect($button.attr('aria-label')).toEqual('Show or hide menu')
216-
})
217210
it('allows label to be customised', () => {
218211
const $ = render('header', examples['with custom menu button label'])
219212

0 commit comments

Comments
 (0)