diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js
index 46816826bb..6e7daa07ab 100644
--- a/src/dropdown/dropdown.js
+++ b/src/dropdown/dropdown.js
@@ -101,7 +101,7 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
}
appendToBody = angular.isDefined($attrs.dropdownAppendToBody);
- keynavEnabled = angular.isDefined($attrs.uibKeyboardNav);
+ keynavEnabled = angular.isDefined($attrs.keyboardNav);
if (appendToBody && !appendTo) {
appendTo = body;
@@ -298,45 +298,6 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
};
})
-.directive('uibKeyboardNav', function() {
- return {
- restrict: 'A',
- require: '?^uibDropdown',
- link: function(scope, element, attrs, dropdownCtrl) {
- element.bind('keydown', function(e) {
- if ([38, 40].indexOf(e.which) !== -1) {
- e.preventDefault();
- e.stopPropagation();
-
- var elems = dropdownCtrl.dropdownMenu.find('a');
-
- switch (e.which) {
- case 40: { // Down
- if (!angular.isNumber(dropdownCtrl.selectedOption)) {
- dropdownCtrl.selectedOption = 0;
- } else {
- dropdownCtrl.selectedOption = dropdownCtrl.selectedOption === elems.length - 1 ?
- dropdownCtrl.selectedOption : dropdownCtrl.selectedOption + 1;
- }
- break;
- }
- case 38: { // Up
- if (!angular.isNumber(dropdownCtrl.selectedOption)) {
- dropdownCtrl.selectedOption = elems.length - 1;
- } else {
- dropdownCtrl.selectedOption = dropdownCtrl.selectedOption === 0 ?
- 0 : dropdownCtrl.selectedOption - 1;
- }
- break;
- }
- }
- elems[dropdownCtrl.selectedOption].focus();
- }
- });
- }
- };
-})
-
.directive('uibDropdownToggle', function() {
return {
require: '?^uibDropdown',
diff --git a/src/dropdown/test/dropdown.spec.js b/src/dropdown/test/dropdown.spec.js
index c03da297f5..e14ca66129 100644
--- a/src/dropdown/test/dropdown.spec.js
+++ b/src/dropdown/test/dropdown.spec.js
@@ -547,7 +547,7 @@ describe('dropdownToggle', function() {
describe('`keyboard-nav` option', function() {
function dropdown() {
- return $compile('
')($rootScope);
+ return $compile('
')($rootScope);
}
beforeEach(function() {
element = dropdown();
@@ -586,7 +586,7 @@ describe('dropdownToggle', function() {
describe('`keyboard-nav` option', function() {
function dropdown() {
- return $compile('
')($rootScope);
+ return $compile('
')($rootScope);
}
beforeEach(function() {
element = dropdown();
@@ -699,7 +699,7 @@ describe('dropdownToggle', function() {
describe('`keyboard-nav` option with `dropdown-append-to-body` option', function() {
function dropdown() {
- return $compile('
')($rootScope);
+ return $compile('
')($rootScope);
}
beforeEach(function() {
@@ -709,7 +709,7 @@ describe('dropdownToggle', function() {
it('should focus first list element when down arrow pressed', function() {
clickDropdownToggle();
- triggerKeyDown(element, 40);
+ triggerKeyDown($document, 40);
var dropdownMenu = $document.find('#dropdown-menu');
@@ -720,8 +720,8 @@ describe('dropdownToggle', function() {
it('should focus second list element when down arrow pressed twice', function() {
clickDropdownToggle();
- triggerKeyDown(element, 40);
- triggerKeyDown(element, 40);
+ triggerKeyDown($document, 40);
+ triggerKeyDown($document, 40);
var dropdownMenu = $document.find('#dropdown-menu');