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

Unexpected error and guidance raised for button with accName from label element #3696

Closed
1 task done
scottaohara opened this issue Oct 4, 2022 · 5 comments · Fixed by #4607
Closed
1 task done

Comments

@scottaohara
Copy link
Contributor

Product

axe-core

Product Version

4.4.2

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

The following code snippet (reduced test case) was flagged as a critical impact error under the button-name rule. However, the button does have an accessible name as it is provided by its parent <label> element.

<label>
  <button role=switch aria-checked=false></button>
  Enable something	
</label>

Example codepen: https://codepen.io/scottohara/pen/vYjrboB
Additional use case for associating a <label> with a <button> provided in pen.

It seems that maybe the rule for checking if a button has an accessible name doesn't take into account that a button can be provided its name via a <label> element association.

===

As a related note to this rule, the "to solve this problem, you need to..." section that accompanies this error ends with

Element's default semantics were not overridden with role="none" or role="presentation"

That seems out of place or incomplete guidance with this rule, as those roles would not be respected on a <button> due to the presentation role conflict resolutions and these roles are ignored outright so long as the button remains focusable.

So that bullet seems like it should either be removed, or it needs to explicitly indicate that the <button> needs to also have the disabled attribute so those roles won't be ignored on the button.

Related to the documentation piece of this issue, I've filed an issue against ARIA in HTML to better expose when role=none | presentation would be allowed on <button> and <input> elements.

@scottaohara scottaohara added the ungroomed Ticket needs a maintainer to prioritize and label label Oct 4, 2022
@straker
Copy link
Contributor

straker commented Oct 4, 2022

I wonder if this is similar to #2488. That one used an explicit label to give a button a name, but we found it didn't work in Dragon Naturally Speaking. I can take a look to see if wrapping the button in an implicit label proves any better for it.

@scottaohara
Copy link
Contributor Author

per the results you have from the codepen test cases you have in that other issue, there are some tests that aren't valid - specifically <div role=button> as being a <div>, it cannot be named by a <label> element. I want to make sure that those aren't being taken into consideration as unsupported instances, when the use case isn't valid.

@straker
Copy link
Contributor

straker commented Oct 4, 2022

Makes sense. I think I did that originally just for completeness of a test case. But I can rule out some of the more invalid cases when we do our retesting.

@scottaohara
Copy link
Contributor Author

scottaohara commented Oct 4, 2022

Would appreciate that. Also, per Wilco's comment in the previous thread, I would completely agree with throwing a warning for support with Dragon (if it's still an issue. haven't checked myself) and that there are honestly better ways to name a button. I'm not going to argue about that at all, naming a button with a label element is kinda weird, but valid. So per other than what is being tested here, wcag conformance vs software support, it would be more accurate to surface this particular pattern as a warning for the potential lack of support - specifically with dragon, than saying it's a flat out failure.

@WilcoFiers WilcoFiers added fix Bug fixes support accessibility support and removed ungroomed Ticket needs a maintainer to prioritize and label labels Aug 1, 2023
@WilcoFiers WilcoFiers added this to the Axe-core 4.9 milestone Aug 1, 2023
@WilcoFiers
Copy link
Contributor

Update: We've tested this out. While explicit labels seem to work in Dragon 16, implicit labels on buttons still do not work, regardless of what role is put on them. Thanks for helping out @mfairchild365!

Michael made a fair point here though, that maybe Dragon shouldn't be in our baseline anymore. There are alternatives to it, including on Windows.

straker added a commit that referenced this issue Oct 16, 2024
… accessible name (#4607)

I'm not sure if this should close #4472 as that also deals with buttons
with a different role running `button-name`. For sure this closes #3696

Closes: #3696

---------

Co-authored-by: Wilco Fiers <[email protected]>
WilcoFiers added a commit that referenced this issue Oct 16, 2024
###
[4.10.1](v4.10.0...v4.10.1)
(2024-10-16)

### Bug Fixes

- **aria-allowed-role:** add form to allowed roles of form element
([#4588](#4588))
([d462d67](d462d67)),
closes
[/github.com/dequelabs/axe-core/blob/develop/lib/standards/html-elms.js#L264](https://github.com/dequelabs//github.com/dequelabs/axe-core/blob/develop/lib/standards/html-elms.js/issues/L264)
- **axe.d.ts:** add typings for preload options object
([#4543](#4543))
([72e269f](72e269f))
- **button-name,input-button-name,input-img-alt:** allow label to give
accessible name
([#4607](#4607))
([364eb72](364eb72)),
closes [#4472](#4472)
[#3696](#3696)
[#3696](#3696)
- **get-ancestry:** add nth-child selector for multiple siblings of
shadow root ([#4606](#4606))
([bdd94a2](bdd94a2)),
closes [#4563](#4563)
- **rules:** Change "alternate text" to "alternative text"
([#4582](#4582))
([31e0f61](31e0f61))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants