1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

Fix issue with double move event firing in typeahead.

Fix test to catch issue.
Fix #5806.
This commit is contained in:
Paul McLanahan 2012-11-09 11:48:21 -05:00
parent 54486de88c
commit 6ec7c72e5b
2 changed files with 19 additions and 2 deletions

View file

@ -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)
}

View 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")