-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(a11y): don't set aria description if it's the same as the node's aria-label #15250
Conversation
e1cba77
to
813ad85
Compare
return false; | ||
} | ||
|
||
const trimmedMessage = message == null ? '' : `${message}`.trim(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
813ad85
to
95f576c
Compare
The feedback has been addressed @jelbourn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
As per a recent discussion, reworks the
AriaDescriber
not to set thearia-describedby
, if the message will be exactly the same as an existingaria-label
on the element. This avoids the same text being read out twice.Fixes #15048.