Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit e3be4d1

Browse files
edclementsaaronroberson
authored andcommittedOct 19, 2016
fix: ensure aria-activedescendant is correct
This is a fix for a severe error found using the Google Accessibility Developer Tool audit: ARIA attributes which refer to other elements by ID should refer to elements which exist in the DOM.
1 parent 51a0836 commit e3be4d1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed
 

‎src/bootstrap/select.tpl.html

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
aria-expanded="true"
55
aria-label="{{ $select.baseTitle }}"
66
aria-owns="ui-select-choices-{{ $select.generatedId }}"
7-
aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}"
87
class="form-control ui-select-search"
98
ng-class="{ 'ui-select-search-hidden' : !$select.searchEnabled }"
109
placeholder="{{$select.placeholder}}"

‎src/select2/select.tpl.html

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
aria-expanded="true"
1313
aria-owns="ui-select-choices-{{ $select.generatedId }}"
1414
aria-label="{{ $select.baseTitle }}"
15-
aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}"
1615
class="ui-select-search select2-input"
1716
ng-model="$select.search">
1817
</div>

‎src/uiSelectController.js

+12
Original file line numberDiff line numberDiff line change
@@ -740,4 +740,16 @@ uis.controller('uiSelectCtrl',
740740
ctrl.searchInput.off('keyup keydown tagged blur paste');
741741
angular.element($window).off('resize', onResize);
742742
});
743+
744+
$scope.$watch('$select.activeIndex', function(activeIndex) {
745+
if (activeIndex)
746+
$element.find('input').attr(
747+
'aria-activedescendant',
748+
'ui-select-choices-row-' + ctrl.generatedId + '-' + activeIndex);
749+
});
750+
751+
$scope.$watch('$select.open', function(open) {
752+
if (!open)
753+
$element.find('input').removeAttr('aria-activedescendant');
754+
});
743755
}]);

0 commit comments

Comments
 (0)