Commit 0b827965 authored by Jacob Thornton's avatar Jacob Thornton

fix regression in typeahead #3313

parent 354f99f0
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
.on('keyup', $.proxy(this.keyup, this)) .on('keyup', $.proxy(this.keyup, this))
if ($.browser.webkit || $.browser.msie) { if ($.browser.webkit || $.browser.msie) {
this.$element.on('keydown', $.proxy(this.keypress, this)) this.$element.on('keydown', $.proxy(this.keydown, this))
} }
this.$menu this.$menu
...@@ -177,55 +177,61 @@ ...@@ -177,55 +177,61 @@
.on('mouseenter', 'li', $.proxy(this.mouseenter, this)) .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
} }
, keyup: function (e) { , move: function (e) {
switch(e.keyCode) { switch(e.keyCode) {
case 40: // down arrow
case 38: // up arrow
break
case 9: // tab case 9: // tab
case 13: // enter case 13: // enter
if (!this.shown) return case 27: // escape
this.select() e.preventDefault()
break break
case 27: // escape case 38: // up arrow
if (!this.shown) return e.preventDefault()
this.hide() this.prev()
break break
default: case 40: // down arrow
this.lookup() e.preventDefault()
this.next()
break
} }
e.stopPropagation() e.stopPropagation()
e.preventDefault() }
, keydown: function (e) {
this.suppressKeyPressRepeat = !~[40,38,9,13,27].indexOf(e.keyCode)
this.move(e)
} }
, keypress: function (e) { , keypress: function (e) {
if (!this.shown) return if (!this.shown || this.suppressKeyPressRepeat) return
this.move(e)
}
, keyup: function (e) {
switch(e.keyCode) { switch(e.keyCode) {
case 40: // down arrow
case 38: // up arrow
break
case 9: // tab case 9: // tab
case 13: // enter case 13: // enter
case 27: // escape if (!this.shown) return
e.preventDefault() this.select()
break break
case 38: // up arrow case 27: // escape
if (e.type != 'keydown') break if (!this.shown) return
e.preventDefault() this.hide()
this.prev()
break break
case 40: // down arrow default:
if (e.type != 'keydown') break this.lookup()
e.preventDefault()
this.next()
break
} }
e.stopPropagation() e.stopPropagation()
e.preventDefault()
} }
, blur: function (e) { , blur: function (e) {
......
...@@ -1763,7 +1763,7 @@ ...@@ -1763,7 +1763,7 @@
.on('keyup', $.proxy(this.keyup, this)) .on('keyup', $.proxy(this.keyup, this))
if ($.browser.webkit || $.browser.msie) { if ($.browser.webkit || $.browser.msie) {
this.$element.on('keydown', $.proxy(this.keypress, this)) this.$element.on('keydown', $.proxy(this.keydown, this))
} }
this.$menu this.$menu
...@@ -1771,55 +1771,61 @@ ...@@ -1771,55 +1771,61 @@
.on('mouseenter', 'li', $.proxy(this.mouseenter, this)) .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
} }
, keyup: function (e) { , move: function (e) {
switch(e.keyCode) { switch(e.keyCode) {
case 40: // down arrow
case 38: // up arrow
break
case 9: // tab case 9: // tab
case 13: // enter case 13: // enter
if (!this.shown) return case 27: // escape
this.select() e.preventDefault()
break break
case 27: // escape case 38: // up arrow
if (!this.shown) return e.preventDefault()
this.hide() this.prev()
break break
default: case 40: // down arrow
this.lookup() e.preventDefault()
this.next()
break
} }
e.stopPropagation() e.stopPropagation()
e.preventDefault() }
, keydown: function (e) {
this.suppressKeyPressRepeat = !~[40,38,9,13,27].indexOf(e.keyCode)
this.move(e)
} }
, keypress: function (e) { , keypress: function (e) {
if (!this.shown) return if (!this.shown || this.suppressKeyPressRepeat) return
this.move(e)
}
, keyup: function (e) {
switch(e.keyCode) { switch(e.keyCode) {
case 40: // down arrow
case 38: // up arrow
break
case 9: // tab case 9: // tab
case 13: // enter case 13: // enter
case 27: // escape if (!this.shown) return
e.preventDefault() this.select()
break break
case 38: // up arrow case 27: // escape
if (e.type != 'keydown') break if (!this.shown) return
e.preventDefault() this.hide()
this.prev()
break break
case 40: // down arrow default:
if (e.type != 'keydown') break this.lookup()
e.preventDefault()
this.next()
break
} }
e.stopPropagation() e.stopPropagation()
e.preventDefault()
} }
, blur: function (e) { , blur: function (e) {
......
This diff is collapsed.
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
.on('keyup', $.proxy(this.keyup, this)) .on('keyup', $.proxy(this.keyup, this))
if ($.browser.webkit || $.browser.msie) { if ($.browser.webkit || $.browser.msie) {
this.$element.on('keydown', $.proxy(this.keypress, this)) this.$element.on('keydown', $.proxy(this.keydown, this))
} }
this.$menu this.$menu
...@@ -177,55 +177,63 @@ ...@@ -177,55 +177,63 @@
.on('mouseenter', 'li', $.proxy(this.mouseenter, this)) .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
} }
, keyup: function (e) { , move: function (e) {
switch(e.keyCode) { if (!this.shown) return
case 40: // down arrow
case 38: // up arrow
break
switch(e.keyCode) {
case 9: // tab case 9: // tab
case 13: // enter case 13: // enter
if (!this.shown) return case 27: // escape
this.select() e.preventDefault()
break break
case 27: // escape case 38: // up arrow
if (!this.shown) return e.preventDefault()
this.hide() this.prev()
break break
default: case 40: // down arrow
this.lookup() e.preventDefault()
this.next()
break
} }
e.stopPropagation() e.stopPropagation()
e.preventDefault() }
, keydown: function (e) {
this.suppressKeyPressRepeat = !~[40,38,9,13,27].indexOf(e.keyCode)
this.move(e)
} }
, keypress: function (e) { , keypress: function (e) {
if (!this.shown) return if (this.suppressKeyPressRepeat) return
this.move(e)
}
, keyup: function (e) {
switch(e.keyCode) { switch(e.keyCode) {
case 40: // down arrow
case 38: // up arrow
break
case 9: // tab case 9: // tab
case 13: // enter case 13: // enter
case 27: // escape if (!this.shown) return
e.preventDefault() this.select()
break break
case 38: // up arrow case 27: // escape
if (e.type != 'keydown') break if (!this.shown) return
e.preventDefault() this.hide()
this.prev()
break break
case 40: // down arrow default:
if (e.type != 'keydown') break this.lookup()
e.preventDefault()
this.next()
break
} }
e.stopPropagation() e.stopPropagation()
e.preventDefault()
} }
, blur: function (e) { , blur: function (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment