diff options
| author | Matty Williams <[email protected]> | 2019-05-29 21:48:59 +0300 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2020-11-30 12:07:51 +0200 |
| commit | b0372bb6588ab12c398e5dbf39950dfd3269575e (patch) | |
| tree | 06167eb1c2ac5542c4b4afdeba21386a013113ff /js | |
| parent | af5744440583e0a13ad637bc41e8e7a4074086fb (diff) | |
| download | bootstrap-b0372bb6588ab12c398e5dbf39950dfd3269575e.tar.xz bootstrap-b0372bb6588ab12c398e5dbf39950dfd3269575e.zip | |
Accessibility update for tooltip.js
Update to the tooltip.js to add an aria-label attribute that contains the original title of the element, but only if the element doesn't have an existing aria-label attribute.
This is to address cases where screen readers are not capturing the aria-describedby attribute that is added when the tooltip is triggered. This should also avoid a race condition between the screen reader and the appearance of the tooltip.
Diffstat (limited to 'js')
| -rw-r--r-- | js/src/tooltip.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 797afb134..936a2a66f 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -584,6 +584,10 @@ class Tooltip extends BaseComponent { if (title || originalTitleType !== 'string') { this._element.setAttribute('data-bs-original-title', title || '') + if (!this._element.getAttribute('aria-label') && !this._element.textContent) { + this._element.setAttribute('aria-label', this._element.getAttribute('title') || '') + } + this._element.setAttribute('title', '') } } |
