Skip to content

Commit eda397c

Browse files
crisbetowagnermaciel
authored andcommitted
fix(material/tooltip): assign role to aria description element
Sets the `tooltip` role on the tooltip's description element so it conveys more information to assistive technology. Fixes #20593.
1 parent fec67cd commit eda397c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/material/tooltip/tooltip.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
207207
@Input('matTooltip')
208208
get message() { return this._message; }
209209
set message(value: string) {
210-
this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message);
210+
this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message, 'tooltip');
211211

212212
// If the message is not a string (e.g. number), convert it to a string and trim it.
213213
// Must convert with `String(value)`, not `${value}`, otherwise Closure Compiler optimises
@@ -225,7 +225,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
225225
// has a data-bound `aria-label` or when it'll be set for the first time. We can avoid the
226226
// issue by deferring the description by a tick so Angular has time to set the `aria-label`.
227227
Promise.resolve().then(() => {
228-
this._ariaDescriber.describe(this._elementRef.nativeElement, this.message);
228+
this._ariaDescriber.describe(this._elementRef.nativeElement, this.message, 'tooltip');
229229
});
230230
});
231231
}
@@ -332,7 +332,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
332332
this._destroyed.next();
333333
this._destroyed.complete();
334334

335-
this._ariaDescriber.removeDescription(nativeElement, this.message);
335+
this._ariaDescriber.removeDescription(nativeElement, this.message, 'tooltip');
336336
this._focusMonitor.stopMonitoring(nativeElement);
337337
}
338338

0 commit comments

Comments
 (0)