Skip to content
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

Should aria-prohibited-attr account for widget parents? #2953

Closed
WilcoFiers opened this issue May 21, 2021 · 3 comments · Fixed by #4541
Closed

Should aria-prohibited-attr account for widget parents? #2953

WilcoFiers opened this issue May 21, 2021 · 3 comments · Fixed by #4541
Assignees
Labels
fix Bug fixes rules Issue or false result from an axe-core rule standards Issues in the ARIA standards objects (lib/standards) support
Milestone

Comments

@WilcoFiers
Copy link
Contributor

The aria-prohibited-attr check flags use of aria-label on elements where it will be ignored. In building that, we did not account for scenarios like the following, where because of the way the accessible name calculation works, the aria-label attribute is used in the name of the parent widget.

<button>
  <span aria-label="hello world"></span>
</button>

We need to do testing on this. Figure out if this works consistently across the supported AT, and if there are any differences between different browsers. For example, do links behave differently than buttons, because links don't have presentational children, but buttons (in some browsers) do. Does it matter if this is a native element, or an element with a role attribute. Does it matter if the element is focusable or not?

I'd like to see someone put together some test cases and try them with JAWS, NVDA & VO.

@WilcoFiers WilcoFiers added this to the axe-core 4.3 milestone May 21, 2021
@WilcoFiers WilcoFiers modified the milestones: axe-core 4.3, Axe-core 4.4 Jul 7, 2021
@WilcoFiers WilcoFiers modified the milestones: Axe-core 4.4, Axe-core 4.5 Nov 10, 2021
@straker
Copy link
Contributor

straker commented May 11, 2022

Tested with the following HTML:

<h2>button</h2>
<button>
  <span aria-label="native button"></span>
</button>

<h2>link</h2>
<a href="#">
  <span aria-label="native link"></span>
</a>

<h2>role=button</h2>
<div role="button" tabindex="0">
  <span aria-label="role button"></span>
</div>

<h2>role=link</h2>
<div role="link" tabindex="0">
  <span aria-label="role link"></span>
</div>
  • VO / Safari - Only the native button was focusable (using tab), announced as "native button, button." I wasn't able to focus the others nor navigate to them using line-by-line. Rotor menu was able to bring up both buttons in the Form Controls menu, both listed using aria-label as the name. Ditto for the Links menu.
  • JAWS / IE11 - Can navigate to each one with either tab or line-by-line, names are announced using the aria-label. Removing the tabindex from the non-native elements did not change the behavior (other than not being able to tab to them).
  • JAWS / Chrome - Same as JAWS / IE11
  • NVDA / Firefox - Same as JAWS / IE11

So it looks like only VO / Safari has issues with it.

@WilcoFiers
Copy link
Contributor Author

Thanks for the testing. That sort of confirms what I was suspecting. So then there isn't really an issue in doing using aria-label on descendants of widgets. Lets add in an exception that for such cases.

@WilcoFiers WilcoFiers added fix Bug fixes standards Issues in the ARIA standards objects (lib/standards) and removed question labels May 19, 2022
@WilcoFiers WilcoFiers modified the milestones: Axe-core 4.5, Axe-core 4.6 May 20, 2022
@straker straker modified the milestones: Axe-core 4.7, Axe-core 4.8 Mar 22, 2023
@straker
Copy link
Contributor

straker commented Jul 25, 2023

This gets a bit more interesting as the following HTML also reads the name of the aria-label in all 3 screen readers / browsers.

<span id="foo" aria-label="foo"></span>

<!-- reads as "foo button" -->
<button aira-labelledby="foo"></button>

<!-- reads as "foo graphic" -->
<div role="img" aria-labelledby="foo"></div>

<!-- reads as "heading level 2 foo" -->
<div role="heading">
  <span aria-label="foo"></span>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fixes rules Issue or false result from an axe-core rule standards Issues in the ARIA standards objects (lib/standards) support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants