Updates the tooltip's ARIA description based on it current state.
(oldMessage: string)
| 911 | |
| 912 | /** Updates the tooltip's ARIA description based on it current state. */ |
| 913 | private _syncAriaDescription(oldMessage: string): void { |
| 914 | if (this._ariaDescriptionPending) { |
| 915 | return; |
| 916 | } |
| 917 | |
| 918 | this._ariaDescriptionPending = true; |
| 919 | this._ariaDescriber.removeDescription(this._elementRef.nativeElement, oldMessage, 'tooltip'); |
| 920 | |
| 921 | // The `AriaDescriber` has some functionality that avoids adding a description if it's the |
| 922 | // same as the `aria-label` of an element, however we can't know whether the tooltip trigger |
| 923 | // has a data-bound `aria-label` or when it'll be set for the first time. We can avoid the |
| 924 | // issue by deferring the description by a tick so Angular has time to set the `aria-label`. |
| 925 | if (!this._isDestroyed) { |
| 926 | afterNextRender( |
| 927 | { |
| 928 | write: () => { |
| 929 | this._ariaDescriptionPending = false; |
| 930 | |
| 931 | if (this.message && !this.disabled) { |
| 932 | this._ariaDescriber.describe(this._elementRef.nativeElement, this.message, 'tooltip'); |
| 933 | } |
| 934 | }, |
| 935 | }, |
| 936 | {injector: this._injector}, |
| 937 | ); |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | /** Determines which events should be routed to the tooltip overlay. */ |
| 942 | private _overlayEventPredicate = (event: Event) => { |
no test coverage detected