Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul McLanahan <paul@mclanahan.net>2012-11-09 20:48:21 +0400
committerPaul McLanahan <paul@mclanahan.net>2012-11-13 20:00:34 +0400
commit6ec7c72e5b5152afb676c43ea57a51fb625f9ba2 (patch)
treeba88af1f8f34870b4238eb568b808f56c17297c1
parent54486de88c7774e83b66dd4d42885300c2692f67 (diff)
Fix issue with double move event firing in typeahead.
Fix test to catch issue. Fix #5806.
-rw-r--r--js/bootstrap-typeahead.js2
-rw-r--r--js/tests/unit/bootstrap-typeahead.js19
2 files changed, 19 insertions, 2 deletions
diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js
index 512d91acb4..26d8452583 100644
--- a/js/bootstrap-typeahead.js
+++ b/js/bootstrap-typeahead.js
@@ -217,7 +217,7 @@
}
, 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)
}
diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js
index 16bdb91948..b796a33b32 100644
--- a/js/tests/unit/bootstrap-typeahead.js
+++ b/js/tests/unit/bootstrap-typeahead.js
@@ -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
+})