]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Accessibility update for tooltip.js
authorMatty Williams <mattyqwilliams@gmail.com>
Wed, 29 May 2019 18:48:59 +0000 (21:48 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 30 Nov 2020 10:07:51 +0000 (12:07 +0200)
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.

js/src/tooltip.js

index 797afb134fd3c600a234029c3f6414140899be24..936a2a66f2fa4f9ee4342a3b7529c0553f3187c5 100644 (file)
@@ -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', '')
     }
   }