Skip to content

Commit

Permalink
fix: ensure Dropdown aria-labelledby to have an ID #11572
Browse files Browse the repository at this point in the history
Closes #11572
  • Loading branch information
ncoden committed Nov 1, 2018
1 parent 4c290be commit 5ddb04b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions js/foundation.dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,20 @@ class Dropdown extends Positionable {
this.$parent = null;
}

// Do not change the `labelledby` if it is defined
var labelledby = this.$element.attr('aria-labelledby')
|| this.$currentAnchor.attr('id')
|| GetYoDigits(6, 'dd-anchor');
// Set [aria-describedby] on the Dropdown if it is not set
if (typeof this.$element.attr('aria-describedby') === 'undefined') {
// Get the anchor ID or create one
if (typeof this.$currentAnchor.attr('id') === 'undefined') {
this.$currentAnchor.attr('id', GetYoDigits(6, 'dd-anchor'));
};

this.$element.attr('aria-labelledby', this.$currentAnchor.attr('id'));
}

this.$element.attr({
'aria-hidden': 'true',
'data-yeti-box': $id,
'data-resize': $id,
'aria-labelledby': labelledby
});

super._init();
Expand Down

0 comments on commit 5ddb04b

Please sign in to comment.