Skip to content

fix(tooltip): avoid adding same aria description as trigger's aria-label #16870

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

Merged
merged 1 commit into from
Sep 9, 2019

Conversation

crisbeto
Copy link
Member

We automatically add an aria-describedby to the triggers of tooltips so that assistive technologies can read out the tooltip text. As a part of this process, the AriaDescriber has some functionality that checks whether the element doesn't have an aria-label with the same value already, and if it does, it avoids adding the description. The problem is that tooltips add this description very early in their lifecycle which means that if the element has a data-bound aria-label, it won't be detected by the AriaDescriber, as is the case for the buttons in the mat-paginator. These changes work around the issue by deferring the setting of the description.

Fixes #16719.

We automatically add an `aria-describedby` to the triggers of tooltips so that assistive technologies can read out the tooltip text. As a part of this process, the `AriaDescriber` has some functionality that checks whether the element doesn't have an `aria-label` with the same value already, and if it does, it avoids adding the description. The problem is that tooltips add this description very early in their lifecycle which means that if the element has a data-bound `aria-label`, it won't be detected by the `AriaDescriber`, as is the case for the buttons in the `mat-paginator`. These changes work around the issue by deferring the setting of the description.

Fixes angular#16719.
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent Accessibility This issue is related to accessibility (a11y) target: patch This PR is targeted for the next patch release labels Aug 24, 2019
@crisbeto crisbeto requested a review from andrewseguin as a code owner August 24, 2019 20:00
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 24, 2019
// same as the `aria-label` of an element, however we can't know whether the tooltip trigger
// has a data-bound `aria-label` or when it'll be set for the first time. We can avoid the
// issue by deferring the description by a tick so Angular has time to set the `aria-label`.
Promise.resolve().then(() => {
Copy link
Member Author

@crisbeto crisbeto Aug 24, 2019

Choose a reason for hiding this comment

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

For the record, I'm not a fan of having to add this, but it's the least evil of all the alternatives I could think of (e.g. doing our own change detection in one of the after*Checked hooks to see if there's an aria-label or adding a MutationObserver).

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

I think this is totally fine; it's another good example of "I need to do some DOM stuff Angular doesn't need to know about"

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Aug 26, 2019
@jelbourn jelbourn merged commit 1006cc2 into angular:master Sep 9, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Paginator] - NVDA lector read buttons twice
4 participants