aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
authorTrey Hunner <treyhunner@gmail.com>2011-04-19 11:04:08 -0700
committerTrey Hunner <treyhunner@gmail.com>2011-04-20 09:03:11 -0700
commitbdfc6d532c68c092a83461a8b76840719294313f (patch)
treef274b64551b7391bfab7468664aa8565090133fa /ui/jquery.ui.autocomplete.js
parent5076f233dbbfc39f29f2be11a9549f262bb471ea (diff)
downloadjquery-ui-bdfc6d532c68c092a83461a8b76840719294313f.tar.gz
jquery-ui-bdfc6d532c68c092a83461a8b76840719294313f.zip
Autocomplete: Fix list traversal bug. Fixes #7269 - autocomplete: holding down arrow keys in Firefox does not traverse list
Use keypress event for listening for arrow keys because Firefox and Opera do not repeat keydown events for these keys.
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r--ui/jquery.ui.autocomplete.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 1685c0652..09bf4b268 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -53,6 +53,7 @@ $.widget( "ui.autocomplete", {
})
.bind( "keydown.autocomplete", function( event ) {
if ( self.options.disabled || self.element.attr( "readonly" ) ) {
+ suppressKeyPress = true;
return;
}
@@ -60,17 +61,21 @@ $.widget( "ui.autocomplete", {
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
+ suppressKeyPress = true;
self._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
+ suppressKeyPress = true;
self._move( "nextPage", event );
break;
case keyCode.UP:
+ suppressKeyPress = true;
self._move( "previous", event );
// prevent moving cursor to beginning of text field in some browsers
event.preventDefault();
break;
case keyCode.DOWN:
+ suppressKeyPress = true;
self._move( "next", event );
// prevent moving cursor to end of text field in some browsers
event.preventDefault();
@@ -112,7 +117,28 @@ $.widget( "ui.autocomplete", {
if ( suppressKeyPress ) {
suppressKeyPress = false;
event.preventDefault();
+ return;
}
+
+ var keyCode = $.ui.keyCode;
+ switch( event.keyCode ) {
+ case keyCode.PAGE_UP:
+ self._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ self._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ self._move( "previous", event );
+ // prevent moving cursor to beginning of text field in some browsers
+ event.preventDefault();
+ break;
+ case keyCode.DOWN:
+ self._move( "next", event );
+ // prevent moving cursor to end of text field in some browsers
+ event.preventDefault();
+ break;
+ }
})
.bind( "focus.autocomplete", function() {
if ( self.options.disabled ) {