Alex Okrushko
Alex Okrushko

Reputation: 7372

typeahead from Bootstrap v2.2.1 skips every other value on key up or down in Firefox

I'm not sure if it's a new bug was introduced to TB or it's me, but it works in Chrome and IE, but doe NOT work in Firefox.

typeahead skips every other value on key up or down when suggestions are shown.

<input type="text" class="manufacturer typeahead" placeholder="manufacturer">
<script type="text/javascript">
$('.manufacturer.typeahead').typeahead({
            "source":['manufacturer 1','manufacturer 2','manufacturer 3', 'manufacturer 4','manufacturer 5','manufacturer 6','manufacturer 7','manufacturer 8'],
            "items":8
        })
<script>

Twitter Bootstrap 2.2.1
jQuery 1.8.3
Firefox 16.0.2

Opened the bug anyway: https://github.com/twbs/bootstrap/issues/5943

DEMO2 (start typing 'm') or Official typeahead demo at TB site (start typing 'a')

Upvotes: 1

Views: 860

Answers (1)

Alex Okrushko
Alex Okrushko

Reputation: 7372

That really was a bug. Here is the fix:

    , move: function (e) {
    if (!this.shown) return

    switch(e.keyCode) {
        case 9: // tab
        case 13: // enter
        case 27: // escape
            e.preventDefault()
            break

        case 38: // up arrow
            e.preventDefault()
            if (e.type=='keydown') this.prev()
            break

        case 40: // down arrow
            e.preventDefault()
            if (e.type=='keydown') this.next()
            break
    }

Upvotes: 1

Related Questions