]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix issue with double move event firing in typeahead. 5862/head
authorPaul McLanahan <paul@mclanahan.net>
Fri, 9 Nov 2012 16:48:21 +0000 (11:48 -0500)
committerPaul McLanahan <paul@mclanahan.net>
Tue, 13 Nov 2012 16:00:34 +0000 (11:00 -0500)
Fix test to catch issue.
Fix #5806.

js/bootstrap-typeahead.js
js/tests/unit/bootstrap-typeahead.js

index 512d91acb403941d9e7f1715b57740676def6bfe..26d8452583cfeabfb699477eb16ebbe238fccdea 100644 (file)
     }
 
   , keydown: function (e) {
-      this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
+      this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
       this.move(e)
     }
 
index 16bdb9194834435f26c4949bad5b83a199f09eea..b796a33b32f7831009c4e095399d5f716c155cda 100644 (file)
@@ -137,10 +137,19 @@ $(function () {
         equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
         ok(typeahead.$menu.find('li').first().hasClass('active'), "first item is active")
 
+        // simulate entire key pressing event
         $input.trigger({
           type: 'keydown'
         , keyCode: 40
         })
+        .trigger({
+          type: 'keypress'
+        , keyCode: 40
+        })
+        .trigger({
+          type: 'keyup'
+        , keyCode: 40
+        })
 
         ok(typeahead.$menu.find('li').first().next().hasClass('active'), "second item is active")
 
@@ -149,6 +158,14 @@ $(function () {
           type: 'keydown'
         , keyCode: 38
         })
+        .trigger({
+          type: 'keypress'
+        , keyCode: 38
+        })
+        .trigger({
+          type: 'keyup'
+        , keyCode: 38
+        })
 
         ok(typeahead.$menu.find('li').first().hasClass('active'), "first item is active")
 
@@ -196,4 +213,4 @@ $(function () {
 
         typeahead.$menu.remove()
       })
-})
\ No newline at end of file
+})