Skip to content

fix(a11y): don't set aria description if it's the same as the node's aria-label #15250

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
Feb 22, 2019

Conversation

crisbeto
Copy link
Member

As per a recent discussion, reworks the AriaDescriber not to set the aria-describedby, if the message will be exactly the same as an existing aria-label on the element. This avoids the same text being read out twice.

Fixes #15048.

@crisbeto crisbeto added Accessibility This issue is related to accessibility (a11y) target: patch This PR is targeted for the next patch release labels Feb 20, 2019
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 20, 2019
@crisbeto crisbeto force-pushed the 15048/aria-describer-aria-label branch from e1cba77 to 813ad85 Compare February 20, 2019 16:01
return false;
}

const trimmedMessage = message == null ? '' : `${message}`.trim();
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary template string literal? Also, omit the == null?

message ? '' : message.trim();

Alternatively,

const trimmedMessage = `${message || ''}`.trim();

The function signature also indicates that message can't be null or undefined. Should it include those?

Copy link
Member Author

Choose a reason for hiding this comment

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

``${message || ''}.trim(); will swallow values like `0` or `false`. Even though the signature doesn't allow these values, we have some cases where the values from the view get passed straight into this method.


// We shouldn't set descriptions if they're exactly the same as the `aria-label` of the element,
// because screen readers will end up reading out the same text twice in a row.
return trimmedMessage ? element.getAttribute('aria-label') !== trimmedMessage : false;
Copy link
Member

Choose a reason for hiding this comment

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

Trim the aria-label as well?

Probably not a big deal, but it might make sense to also normalize the whitespace for both.

…aria-label

As per a recent discussion, reworks the `AriaDescriber` not to set the `aria-describedby`, if the message will be exactly the same as an existing `aria-label` on the element. This avoids the same text being read out twice.

Fixes angular#15048.
@crisbeto crisbeto force-pushed the 15048/aria-describer-aria-label branch from 813ad85 to 95f576c Compare February 20, 2019 21:48
@crisbeto
Copy link
Member Author

The feedback has been addressed @jelbourn.

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

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Feb 21, 2019
@jelbourn jelbourn merged commit 1bc8bc4 into angular:master Feb 22, 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 Sep 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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make aria-describedby optional for matTooltip
4 participants