Skip to content

Commit e0fd17e

Browse files
committed
Add accessibility support for a select2 label.
1 parent 6d51519 commit e0fd17e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

stanford-slate-enhancements.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ var StanfordSlateEnhancements = StanfordSlateEnhancements || (function(){
185185
var $selectInput = $select.closest('.form_select').find('.form_responses select');
186186
$selectInput.select2(options);
187187

188+
// Fix accessibility issue where if a label exists it doesn't point to the select2 widget.
189+
var selectID = $selectInput.attr('id');
190+
$('label[for="' + selectID + '"]').attr('for', 'select2-' + selectID + '-container');
191+
188192
// Make the input box take focus when opened.
189193
$selectInput.on('select2:open', function(e) {
190194
$('.select2-search__field').get(0).focus();

0 commit comments

Comments
 (0)