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

Commit

Permalink
fix: ensure aria-activedescendant is correct
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edclements authored and aaronroberson committed Oct 19, 2016
1 parent 51a0836 commit e3be4d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/bootstrap/select.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
aria-expanded="true"
aria-label="{{ $select.baseTitle }}"
aria-owns="ui-select-choices-{{ $select.generatedId }}"
aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}"
class="form-control ui-select-search"
ng-class="{ 'ui-select-search-hidden' : !$select.searchEnabled }"
placeholder="{{$select.placeholder}}"
Expand Down
1 change: 0 additions & 1 deletion src/select2/select.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
aria-expanded="true"
aria-owns="ui-select-choices-{{ $select.generatedId }}"
aria-label="{{ $select.baseTitle }}"
aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}"
class="ui-select-search select2-input"
ng-model="$select.search">
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,4 +740,16 @@ uis.controller('uiSelectCtrl',
ctrl.searchInput.off('keyup keydown tagged blur paste');
angular.element($window).off('resize', onResize);
});

$scope.$watch('$select.activeIndex', function(activeIndex) {
if (activeIndex)
$element.find('input').attr(
'aria-activedescendant',
'ui-select-choices-row-' + ctrl.generatedId + '-' + activeIndex);
});

$scope.$watch('$select.open', function(open) {
if (!open)
$element.find('input').removeAttr('aria-activedescendant');
});
}]);

0 comments on commit e3be4d1

Please sign in to comment.