Problem/Motivation

The header pattern handles modals for mobile search and menu.
These modals have currently some accessibility issues :
- the search modal doesn't have an accessible name (necessary for assistive technologies like screen readers)
- the "open" button for the menu has an erroneous aria-haspopup="menu" : this attribute is not mandatory, but if present, it should be "dialog" (a "menu" here doesn't mean a website navigation, but more like a native application menu, which is not our case)
- the "close" buttons have the same text/title, which makes them not explicit enough (and also the title attribute should be used only to complement the button text, it has no use if it's a simple repeat)

Steps to reproduce

Populate the header pattern with a search bar.
On a small window or mobile phone, navigate the header with a screenreader, or "inspect accessibility properties".
Open the search modal : it says only "dialog" (contrary to the menu modal which says "menu"), its accessible name is "null".
Tabulate to the close button : it says only "close", its accessible name is "close", as is its inside text.
The problem is the same for the close button in the menu modal.

Proposed resolution

Add an id attribute on the opening button of the search modal, and an aria-labelledby attribute on the search modal to point on that id, so that the button text ("Search") is use as the modal name (same technique used currently for the menu modal).
Modify/add the aria-haspopup attribute on the "open" buttons so that it indicates "dialog", or delete it.
Modify the title attributes on the "close" buttons so that they have each their own, and complement their inside text : "Close search" and "Close menu".

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mh_nichts created an issue. See original summary.

mh_nichts’s picture

Issue summary: View changes

mh_nichts’s picture

I've made a proposal.
For the aria-haspopup attribute, I just changed it to "dialog" : I didn't delete it, and I didn't add one on the search "open" button, to stay closest to the DSFR documentation (https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/en...). Nevertheless we will open an issue on the DSFR side to fix their code.

mh_nichts’s picture

Status: Active » Needs review
pdureau’s picture

Assigned: Unassigned » pdureau

i will have a look

mh_nichts’s picture

Issue créée côté DSFR pour aria-haspopup : https://github.com/GouvernementFR/dsfr/issues/744

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Needs work

Hi,

You have added id="fr-btn-search-mobile" and moved id="fr-btn-menu-mobile"

Is it safe to have such hardcoded ID? What may happen if we have many header component in the page?

(it is a real question, not a rhetorical one)

If hardcoding those ID is an issue, you can introduce a new header_id string prop ("textfield setting") then (non-tested non-authoritative proposal):

{% set header_id = header_id|default("header-" ~ random() ) %}
...
<button class="fr-btn--search fr-btn" data-fr-opened="false" aria-controls="{{ search_mid }}" title="{{ 'Search'|t }}" id="{{ header_id }}-search-mobile">
...
<button class="fr-btn--menu fr-btn" data-fr-opened="false" aria-controls="{{ mobile_menu_mid }}" aria-haspopup="dialog" title="{{ 'Menu'|t }}" id="{{ header_id }}-menu-mobile">
...
<div class="fr-header__search fr-modal" id="{{ search_mid }}" aria-labelledby="{{ header_id }}-search-mobile">
...
<div class="fr-header__menu fr-modal" id="{{ mobile_menu_mid }}" aria-labelledby="{{ header_id }}-menu-mobile">

What do you think?

PS: There are also search_mid & mobile_menu_mid which may be problematic but they don't come from your MR and will be fixed in #3380233: [beta4] Always use default() filter with random function()

pdureau’s picture

Title: Accessibility issues in header modals (id/aria-labelledby, button title) » [beta4] Accessibility issues in header modals (id/aria-labelledby, button title)
mh_nichts’s picture

Sorry about all the separate pushes, but MR should be OK now :)

mh_nichts’s picture

Status: Needs work » Needs review
pdureau’s picture

Status: Needs review » Needs work

header_id was added but not defined in templates/patterns/header/header.ui_patterns.yml

mh_nichts’s picture

Status: Needs work » Needs review

  • pdureau committed 8069686f on 1.0.x authored by mh_nichts
    git commit -m 'Issue #3381866 by mh_nichts: Accessibility issues in...
pdureau’s picture

Status: Needs review » Fixed

Thanks

pdureau’s picture

Status: Fixed » Closed (fixed)