]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Escape key should only close Dropdown 14722/head
authorfat <jacobthornton@gmail.com>
Fri, 3 Oct 2014 03:43:03 +0000 (20:43 -0700)
committerfat <jacobthornton@gmail.com>
Fri, 3 Oct 2014 04:11:17 +0000 (21:11 -0700)
js/dropdown.js

index 756fc21f55e8caf5f61810148d1bbd02753232e2..8fa712775a3ab8dfc75d1ee4d71c614cac1fbaff 100644 (file)
@@ -55,7 +55,7 @@
   }
 
   Dropdown.prototype.keydown = function (e) {
-    if (!/(38|40|27)/.test(e.keyCode)) return
+    if (!/(38|40|27|32)/.test(e.which)) return
 
     var $this = $(this)
 
@@ -67,7 +67,7 @@
     var $parent  = getParent($this)
     var isActive = $parent.hasClass('open')
 
-    if (!isActive || (isActive && e.keyCode == 27)) {
+    if ((!isActive && e.which != 27) || (isActive && e.which == 27)) {
       if (e.which == 27) $parent.find(toggle).trigger('focus')
       return $this.trigger('click')
     }
@@ -79,8 +79,8 @@
 
     var index = $items.index($items.filter(':focus'))
 
-    if (e.keyCode == 38 && index > 0)                 index--                        // up
-    if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
+    if (e.which == 38 && index > 0)                 index--                        // up
+    if (e.which == 40 && index < $items.length - 1) index++                        // down
     if (!~index)                                      index = 0
 
     $items.eq(index).trigger('focus')