magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.36k stars 9.28k forks source link

Accessibility: WAI-ARIA roles nesting wrong in menu #35889

Open plastikschnitzer opened 1 year ago

plastikschnitzer commented 1 year ago

Preconditions and environment

Steps to reproduce

Navigate to storeview analyze html code of menu for correct ARIA markup

Expected result

Menu should be structured according to ARIA schema the following way:

<ul role="menu">
 <li role="none">
  <a href="" role="menuitem">link</a>
 </li>
</ul>

Actual result

<ul role="menu">
 <li>
  <a href="" role="menuitem">link</a>
 </li>
</ul>

As the li tag has no role, the child element for the menu role is missing and the parent element for the menuitem role is missing.

Users who rely on accessibility tools might run into a deadend here.

Additional information

This is also a ranking factor for search engines and part of the lighthouse check, should be fixed!

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @plastikschnitzer. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

plastikschnitzer commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @plastikschnitzer. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @plastikschnitzer, here is your Magento Instance: https://fa8bb1ac816acdac54a2555f850e34c5.instances.magento-community.engineering Admin access: https://fa8bb1ac816acdac54a2555f850e34c5.instances.magento-community.engineering/admin_526c Login: 368d8f43 Password: 5b7a871d26eb

plastikschnitzer commented 1 year ago

Yes, I can confirm the issue can be reproduced on Magento-2.4-develop

m2-assistant[bot] commented 1 year ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November, here is your Magento Instance: https://fa8bb1ac816acdac54a2555f850e34c5.instances.magento-community.engineering Admin access: https://fa8bb1ac816acdac54a2555f850e34c5.instances.magento-community.engineering/admin_411d Login: 16c4a72f Password: 0883c424c168

engcom-November commented 1 year ago

Hi @plastikschnitzer , Thank you for reporting and collaboration. Verified the behavior on Magento 2.4-develop branch and is reproducible. But however, Accessibility: WAI-ARIA is not mentioned anywhere in Magento docs instead mentioned as Web Content Accessibility Guidelines (WCAG) 2.0. Kindly refer the document and provide supporting docs/proofs that support ARIA compliance for Magento pages. Thank you.

plastikschnitzer commented 1 year ago

Thank you @engcom-November thank you for confirming and I am happy to precise further: I was stumbling over this issue running a default google lighthouse test on the shop: https://web.dev/measure Accessibility and UX is becoming more and more a ranking factor in search engines, Magento provides the role element already, but it needs a slight modification as stated in my opening posting with the code proposal, it should work then as expected by WAI-ARIA and search engines will be happy ;-) Further details can be found on the WAI-ARIA documentation: https://www.w3.org/TR/wai-aria-1.1/#menu and https://www.w3.org/TR/wai-aria-1.1/#menuitem

As the nesting in Magento has the <li> element without any role in between the <ul role="menu"> and <a href="" role="menuitem">, the WAI-ARIA compatibility check fails as it expects a role on the <li>. <li role="none"> or <li role="presentation"> excludes the <li> from the nesting tree and the test will be passed.

Check https://www.w3.org/TR/wai-aria-1.1/#presentation and its examples.

plastikschnitzer commented 1 year ago

I have a quick fix which works for the product category menu, insert the code into Content –> Configuration –> Edit on highest level –> Footer –> Miscellaneous HTML

<script>
let mainnav = document.getElementById("store.menu");
let addmenurole = mainnav.getElementsByTagName("li");
for (let i = 0; i < addmenurole.length; i++) {
  addmenurole[i].setAttribute("role","none");}
</script>

This will add role="none" to the li of the main menu and fix the WAI-ARIA compatibility issues. A proper fix should be introduced in the same place where the other role attributes are set, this is just a quick temporary fix, also to demonstrate how the markup should look like.

engcom-November commented 1 year ago

Thank you for the response @plastikschnitzer . We are considering this as feature request but not a bug as WAI-ARIA compliance is not mentioned anywhere in Magento docs.

loic-paquin commented 1 year ago

This demo website is in 2.4.0 : demo

As you can see the <li> in the menu have the attribute role="presentation" Also my websites in 2.4.3 does not have the issue. My websites in 2.4.4 have the issue.

It is not a feature request since it was working properly in the previous versions.

mirianstangherlin commented 2 months ago

@magento I am working on this

m2-assistant[bot] commented 2 months ago

Hi @mirianstangherlin! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

mirianfalconi commented 2 months ago

@magento I am working on this