Page MenuHomePhabricator

FavoriteButton is missing accessible attributes
Closed, ResolvedPublicBUG REPORT

Description

The FavoriteButton is missing some accessibility attributes on the <button> element:

  • aria-role="button"
  • aria-labelledby on the button, pointing to the child oo-ui-labelElement-label element, which needs to be updated to contain the (already invisible) label. This is not actually required, per MDN: "the accessible name for a <button>, <a>, or <td> comes from the text between the opening and closing tags." So as long as we add a label, this will be accessible.
  • aria-pressed attribute because it's a toggle button. Shouldn't be used if the label is dynamically changed.

Event Timeline

Aklapper renamed this task from FavoriteButton is missing accessible atrributes to FavoriteButton is missing accessible attributes.Mar 27 2025, 8:35 AM
Aklapper added a project: Accessibility.

Change #1131873 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/TemplateData@master] Add label, title, and aria attributes to FavoriteButton

https://gerrit.wikimedia.org/r/1131873

Does it make sense (i.e. is it required for screen reader accessibility) to use the same text for the title and label?

<button type="button" class="oo-ui-inputWidget-input oo-ui-buttonElement-button" title="Remove template from favorites" aria-role="button" aria-pressed="true">
    <span class="oo-ui-iconElement-icon oo-ui-icon-bookmark"></span>
    <span class="oo-ui-labelElement-label oo-ui-labelElement-invisible">Remove template from favorites</span>
    <span class="oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator"></span>
</button>

The inner text in .oo-ui-labelElement-label is not visible.

Change #1131873 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Add label, title, and aria-role to FavoriteButton

https://gerrit.wikimedia.org/r/1131873

In reply to my comment above: it's fine to have the same text as tooltip and label.

I think this can be resolved without QA, given how busy QA engineers are at the moment. Any remaining issues will be picked up in the overall review.

<button type="button" class="oo-ui-inputWidget-input oo-ui-buttonElement-button" title="Remove template from favorites" aria-role="button" aria-pressed="true">

button has an implicit role of button, you don't have to set it explicitly. See the technical summary https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#technical_summary

role=button is for when you fake a button with a span or something similar.

Ah, of course, thanks! I'll remove the attr.

Change #1132805 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/TemplateData@master] Remove aria-role=button from a button element

https://gerrit.wikimedia.org/r/1132805

Change #1132805 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Remove aria-role=button from a button element

https://gerrit.wikimedia.org/r/1132805

In the end, not much to be done here (the main actual addition is the tooltip, which switches based on the state of the button). As QA are engaged elsewhere at the moment, I think we can close this now.