Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

mdTooltip: Aria-label added for md-tooltip but not interpolated. #6855

Closed
ErinCoughlan opened this issue Jan 27, 2016 · 6 comments
Closed

mdTooltip: Aria-label added for md-tooltip but not interpolated. #6855

ErinCoughlan opened this issue Jan 27, 2016 · 6 comments
Assignees
Labels
a11y This issue is related to accessibility g3: reported The issue was reported by an internal or external product team. has: Pull Request A PR has been created to address this issue P2: required Issues that must be fixed.
Milestone

Comments

@ErinCoughlan
Copy link
Contributor

md-tooltip adds an aria-label to the element (source), but if the text in the md-tooltip is {{ text }}, the aria-label is also set to {{ text }}. When the text is displayed in the tooltip, it's correctly interpolated, but the aria-label is still wrong.

@ErinCoughlan ErinCoughlan added the g3: reported The issue was reported by an internal or external product team. label Jan 27, 2016
@jelbourn jelbourn added the a11y This issue is related to accessibility label Jan 27, 2016
@jelbourn jelbourn added this to the 1.1.0 milestone Jan 27, 2016
@jelbourn jelbourn added the P2: required Issues that must be fixed. label Jan 27, 2016
@jelbourn
Copy link
Member

@marcysutton do you know anything about tooltip aria-labels ?

@oemmes
Copy link

oemmes commented Jan 27, 2016

I just stumbled upon this issue, too. Would be nice if it gets fixed.

As a workaround one can add the aria-label attribute on the parent manually with the same (interpolated) value, though that's quite some work and duplication if there are lots of tooltips...

@marcysutton
Copy link
Contributor

Text put into a tooltip is copied to a parent button element so it has text in it when the user focuses on the button...waiting for the tooltip to show wouldn't guarantee enough time for assistive technology to catch it. The demos show aria-label hard-coded, but it's redundant since mdTooltip copies that text anyway. I think it just needs to be compiled instead of grabbing .text() directly.

@oemmes which parent element are you putting it on? The aria-label attribute needs to be on a button or other focusable element so it will be announced in a screen reader.

@jelbourn
Copy link
Member

Compiling it would be a bad idea- that could lead to xss. Using $interpolate should be safe, though.

@oemmes
Copy link

oemmes commented Jan 28, 2016

@marcysutton I'm using the tooltip for an md-button, so I put the aria-label on md-button like this:

<md-button aria-label="{{'configurator.actions.share' | translate}}" class="md-fab md-raised" ng-click="shareArticle()">
    <md-tooltip>{{'configurator.actions.share' | translate}}</md-tooltip>
    <md-icon class="icon icon-share"></md-icon>
</md-button>

On the other hand it would be nice if one could use md-tooltip as an attribute on an (focusable) element which has a title or an aria-label attribute. md-tooltip would fetch the title or aria-label and create the tooltip for it. Markup could be then:

<md-button aria-label="{{'configurator.actions.share' | translate}}" md-tooltip class="md-fab md-raised" ng-click="shareArticle()">
    <md-icon class="icon icon-share"></md-icon>
</md-button>

@jelbourn
Copy link
Member

Additional report from @kbae00

When the parent of an md-tooltip doesn't have an aria-label, the addAriaLabel function in tooltip.js adds one by setting the aria-label value to "element.text().trim()". In the case of a particular directive I'm working on, the value passed into the directive uses variables. These are fine for the md-tooltip in the directive template, but the aria-label that gets set on the parent element becomes "{{variable1 name}} ({{variable2 name}})" and that is what a screen reader ends up verbalizing: "left brace left brace variable1 name right brace right brace...". I suspect this is happening because of the way the aria-label is being set "element.text().trim()". It would be nice to have the interpreted values work as aria labels and to not have to explicitly set an aria-label on the parent to get around this.

@crisbeto crisbeto added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Apr 22, 2016
crisbeto added a commit to crisbeto/material that referenced this issue Apr 22, 2016
…-label

Fixes the raw tooltip text text being added to the parent, if a tooltip contained a data binding, instead of the interpolated value.

Fixes angular#6855.
@crisbeto crisbeto added has: Pull Request A PR has been created to address this issue and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Apr 22, 2016
crisbeto added a commit to crisbeto/material that referenced this issue May 26, 2016
…-label

Fixes the raw tooltip text text being added to the parent, if a tooltip contained a data binding, instead of the interpolated value.

Fixes angular#6855.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a11y This issue is related to accessibility g3: reported The issue was reported by an internal or external product team. has: Pull Request A PR has been created to address this issue P2: required Issues that must be fixed.
Projects
None yet
Development

No branches or pull requests

6 participants