Skip to content

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

@scottaohara

Description

@scottaohara

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions