Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
feat(tabIndex): make w11k-select accessible via keyboard with the tab…
Browse files Browse the repository at this point in the history
… key

Closes #19
  • Loading branch information
Philipp Burgmer committed Feb 2, 2016
1 parent 797aff0 commit a3196bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/w11k-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,16 @@ angular.module('w11k.select').directive('w11kSelect', [
jqWindow.off('resize', adjustHeight);
});

scope.onKeyPressedOnDropDownToggle = function ($event) {
// enter or space
if ($event.keyCode === 13 || $event.keyCode === 32) {
$event.preventDefault();
$event.stopPropagation();

scope.dropdown.toggle();
}
};

function updateHeader() {
if (angular.isDefined(scope.config.header.text)) {
jqHeaderText.text(scope.$parent.$eval(scope.config.header.text));
Expand Down
2 changes: 1 addition & 1 deletion src/w11k-select.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="header-placeholder text-muted" ng-show="isEmpty()">Filter</span>
<span class="header-text" ng-hide="isEmpty()"></span>
</div>
<div class="input-group-addon">
<div class="input-group-addon" tabindex="0" ng-keypress="onKeyPressedOnDropDownToggle($event)">
<i class="fa" ng-class="{ 'fa-chevron-down': !dropdown.isOpen(), 'fa-chevron-up': dropdown.isOpen(), 'icon-dropdown-open': !dropdown.isOpen(), 'icon-dropdown-closed': dropdown.isOpen() }"></i>
</div>
</div>
Expand Down

0 comments on commit a3196bc

Please sign in to comment.