Skip to content

fix(a11y): add aria-label where title is used - #1475

Draft
caugner wants to merge 14 commits into
mainfrom
959-accessible-tooltips
Draft

caugner wants to merge 14 commits into
mainfrom
959-accessible-tooltips

Conversation

@caugner

@caugner caugner commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Description

Add aria-label where title is used.

Also adds an ESLint rule to ensure this going forward.

Motivation

title is not accessible to screen-readers.

Additional details

Related issues and pull requests

Fixes #959.

@github-actions

github-actions Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

8052944 was deployed to: https://fred-pr1475.review.mdn.allizom.net/

@caugner
caugner marked this pull request as ready for review April 13, 2026 12:01
@caugner
caugner requested a review from a team as a code owner April 13, 2026 12:01
@caugner
caugner requested a review from LeoMcA April 13, 2026 12:01
Comment thread build/eslint-fred.js Outdated
Comment thread build/eslint-fred.js Outdated
Comment thread build/eslint-fred.js Outdated
Comment thread build/eslint-fred.js
@caugner
caugner requested a review from LeoMcA April 15, 2026 12:56
Comment thread components/compat-table/element.js Outdated

const hasHistory = notes.length > 0;
const isExpanded = hasHistory && this._showTimelineId == timelineId;
const toggleTitle = ifDefined(hasHistory && "Toggle history");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug from before, but I think this'll evaludate to title=false in DOM - need:

Suggested change
const toggleTitle = ifDefined(hasHistory && "Toggle history");
const toggleTitle = ifDefined(hasHistory ? "Toggle history" : undefined);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought undefined renders as "undefined", but IIRC I've seen nothing do the trick:

Suggested change
const toggleTitle = ifDefined(hasHistory && "Toggle history");
const toggleTitle = hasHistory ? "Toggle history" : nothing;

Comment thread components/baseline-indicator/server.js Outdated
key=${name}
class="engine"
title=${title}
aria-label=${title}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<span> is role="generic" by default, and aria-label is prohibited/ignored on generic elements.

So perhaps we'll need a list of GENERIC_TAGS, which we ignore, unless role is set to a non-ignored value.

And we ignore all roles in this list: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label#associated_roles

Comment on lines +74 to 75
aria-label=${title}
>${this.l10n("compat-link-report-missing")`Report this issue`}</a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This linter might be too much of a blunt instrument, there's a number of examples like this where we have a label shown in UI, but then an even more descriptive one in aria-label.

This fails https://www.w3.org/WAI/WCAG21/Understanding/label-in-name: AIUI for users using visible labels, but speech input, they'll say something like "click report this issue", but this element will be represented within the accessibility tree as "Report missing compatibility data" and they won't be able to.

For this reason, when a visible label already exists, aria-label should be avoided or used carefully, and aria-labelledby should be used as a supplement with care.

So perhaps our original premise: use aria-label everywhere we use title is a false one? Let's discuss

@caugner
caugner marked this pull request as draft April 16, 2026 18:04
@caugner
caugner force-pushed the 959-accessible-tooltips branch from a845161 to de703f0 Compare September 16, 2026 16:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessible tooltips

3 participants