Skip to content
This repository was archived by the owner on Aug 29, 2021. It is now read-only.

Commit b5cdfd7

Browse files
committed
Fixes
* Also update the ng-model value on **de**select. * kbItem disables tabbing to :tabbable elements. (Ensures using tab between lists and arrow keys between items)
1 parent fc843d6 commit b5cdfd7

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/directives/KbContainerController.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,19 @@ angular.module('keyboard').factory('KbContainerController', function (undefined,
7777
* @param {*} model
7878
*/
7979
deselect: function (model) {
80+
if (!this.ngModel) {
81+
return;
82+
}
8083
var index = this.selected.indexOf(model);
8184
if (index !== -1) {
8285
this.selected.splice(index, 1);
86+
if (this.multiple) {
87+
this.ngModel.$setViewValue(this.selected);
88+
} else {
89+
this.ngModel.$setViewValue(undefined);
90+
}
8391
}
92+
8493
},
8594
/**
8695
* Select or deselect the given model.

src/directives/kbItem.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ angular.module('keyboard').directive('kbItem', function (KbItemController, $anim
99
link: function ($scope, el, attrs, controllers) {
1010
var kbItem = controllers[0];
1111
var kbContainer = controllers[1];
12-
var tagName = el[0].tagName;
12+
var isTabbable = (el[0].tagName === 'A' || el[0].tagName === 'BUTTON' || el[0].tagName === 'AREA');
1313

1414
for (var i = 1; i < controllers.length; i++) {
1515
if (controllers[i]) {
@@ -52,8 +52,8 @@ angular.module('keyboard').directive('kbItem', function (KbItemController, $anim
5252
$animate.addClass(el, activeClass);
5353
} else {
5454
$animate.removeClass(el, activeClass);
55-
if (tagName === 'A' || tagName === 'BUTTON') {
56-
el.attr('tabindex', 0);
55+
if (isTabbable) {
56+
el.attr('tabindex', -1);
5757
} else {
5858
el.removeAttr('tabindex');
5959
}

0 commit comments

Comments
 (0)