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

Button element does not accept aria-label as a valid name for accessibility #160

Closed
mattdell opened this issue Mar 10, 2016 · 20 comments
Closed

Comments

@mattdell
Copy link

This markup

<button name="next" aria-label="my icon button" type="button">
  <span class="dd-icon glyph glyphicon-heart" aria-hidden="true"></span>
</button>

Throws this error

This button element does not have a name available to an accessibility API. Valid names are: title attribute, element content.

Principle: Robust
Techniques: H91

Looking at the rules for H91 button I see very clearly

Name: text inside element or 'title' attribute

For which my code has neither.

However, aria-label is a valid name available to an accessibility API. In fact, by most screen readers it is preferred: http://www.deque.com/blog/text-links-practices-screen-readers/

Both aria-label and the title are listed in the text alternative computation algorithm with the title having the lowest preference

Has this been given consideration?

@luketw
Copy link
Member

luketw commented Apr 28, 2016

Hi Matt,

Thanks for your suggestion. I'll probably have to look into this in conjunction with #156 #157 #158 #159, and I've included sort-of a note-to-self to review the ARIA docs again at #162.

From my reading of things, especially HTML-AAPI, I agree with you - the above WG note states the order should be based on "aria-labelledby", followed by "aria-label", followed by the relevant HTML attributes. This is also in line with the note in WCAG2-TECHS#ARIA6 which warns that "aria-label" will override the HTML attributes.

ironikart added a commit that referenced this issue Aug 25, 2016
…ledby and aria-label will be picked up as one of the required attributes on specified element types and checked for validity. This addresses #160 and paves the way for #159, #158, #157 and #156. Also references #162.
@ironikart ironikart self-assigned this Aug 25, 2016
@Heydon
Copy link

Heydon commented May 26, 2017

@luketw @mattdell Hi! Yes, aria-labelledby would take precedence over aria-label, which would take precedence over other naming techniques. Both aria-labelledby and aria-label are valid naming/labeling methods and well supported across UAs / ATs. There should be no error here.

@KittyGiraudel
Copy link

Hello,

I still have the problem running pa11y-ci@1.1.1, which runs pa11y@4.7.0, which bundles HTML_CodeSniffer@2.0.7.

 • This button element does not have a name available to an accessibility API. Valid
   names are: title attribute, element content.

   (#main > div > header > div > div:nth-child(1) > div > div:nth-child(2) > button)

   <button class="w aw y ax ay az ba bb bc bd be bf bg bh au bi bj at qa-backButton"
   type="button" disabled="" aria-label="Go back" data-reactid="16"><!-- react-empty: 17
   --><svg cl...</button>

It seems like HTML_CodeSniffer@2.0.7 does not include the fix. Correct?

@ironikart
Copy link
Contributor

It seems like HTML_CodeSniffer@2.0.7 does not include the fix. Correct?

@hugogiraudel That is correct, the change is on the master branch which hasn't been tagged with a release yet. You could build from master if you were keen on getting the fix asap.

@XhmikosR
Copy link

Well, this bug affects every project that depends on this library, which is a lot. So a fix should be published from your side as soon as possible.

@KittyGiraudel
Copy link

KittyGiraudel commented May 29, 2017

Thanks for the quick reply! However —as @XhmikosR said— given it’s clearly a (small) bug in HTML_CodeSniffer, and given you also found, reviewed and merged a clean fix for it, isn’t there a way we could publish it as 2.0.8?

@ironikart
Copy link
Contributor

@XhmikosR @hugogiraudel I've released the fix in 2.1.0

@XhmikosR
Copy link

Thanks!

@KittyGiraudel
Copy link

Very cool, thank you!

@KittyGiraudel
Copy link

KittyGiraudel commented Jun 19, 2017

Same goes for a tags: WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent. Is it expected?

@ironikart ironikart reopened this Jun 19, 2017
@ironikart
Copy link
Contributor

@hugogiraudel Looking at the code I think you are correct, there should be some label detection here. Re-opening and will look at adding it.

ironikart added a commit that referenced this issue Jun 19, 2017
@KittyGiraudel
Copy link

@ironikart Thanks! :)

@72gm
Copy link

72gm commented Dec 21, 2017

I still seem to be getting this error? This markup looks correct to me?

image

@ironikart
Copy link
Contributor

It looks correct to me but the code that was changed most recently only affects buttons and hyperlinks. I will re-open this and investigate for other element types.

@chavab1
Copy link

chavab1 commented Mar 23, 2018

Wondering if the change had been implemented yet. I'm getting the same error. I have a div with a role=button attribute. I've included a title and an aria-label but it still triggers the same error documented on this thread.

@ironikart
Copy link
Contributor

@chavab1 This issue snuck under the radar for a bit, apologies. I've pushed up a fix for this now but won't be available in the bookmarklet until our next release.

@chavab1
Copy link

chavab1 commented Mar 26, 2018

OK, sounds good. I'll be on the lookout for the next release.
Thanx

@72gm
Copy link

72gm commented Apr 30, 2018

Hi, When are you likely to push a new release?
Thanks

@barrypoore
Copy link

I'm getting this:

This button element does not have a name available to an accessibility API. Valid names are: title undefined, element content, aria-label undefined, aria-labelledby undefined.

<button class="mini-cart_button" name="cart" dropdown-toggle"="" id="mini-cart" data-toggle="dropdown" data-count="0" aria-expanded="false" value="cart"> <span class="p...

Does this mean my code is wrong or is it an error of the code sniffer widget?

@ironikart
Copy link
Contributor

The sniffer was unable to find some text to describe the button to a screen reader. The suggestions are to add attributes like title, aria-label or aria-labelledby (if there is another element that has descriptive text for this button), or to have content in the button itself. If you think there is something wrong with the detection and it has descriptive text just paste the the full html snippet of this button and I can confirm for you.

dochne pushed a commit to silktide/HTML_CodeSniffer that referenced this issue Mar 8, 2021
dochne pushed a commit to silktide/HTML_CodeSniffer that referenced this issue Mar 8, 2021
…a labels to pass as valid names for an accessibility API. This will trigger on any element using that role. This resolves squizlabs#160.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants