aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.autocomplete.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-10-17 08:09:53 -0400
committerScott González <scott.gonzalez@gmail.com>2011-10-17 08:11:23 -0400
commit63374dcb520f5ad7104ccb57b8eb01dca4087889 (patch)
tree9f52a68ddcc613d11c962efb57d27f68c91f50d7 /ui/jquery.ui.autocomplete.js
parentd4d8d74b10431933aadca19248c15e36fbb35a03 (diff)
downloadjquery-ui-63374dcb520f5ad7104ccb57b8eb01dca4087889.tar.gz
jquery-ui-63374dcb520f5ad7104ccb57b8eb01dca4087889.zip
Autocomplete: Avoid handling keypress when keydown modified the search term. Fixes #7799 - Autocomplete regression - Cannot type '&' in IE and Chrome.
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r--ui/jquery.ui.autocomplete.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 2618597b1..6b9ee4b3a 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -48,7 +48,15 @@ $.widget( "ui.autocomplete", {
_create: function() {
var self = this,
doc = this.element[ 0 ].ownerDocument,
+ // Some browsers only repeat keydown events, not keypress events,
+ // so we use the suppressKeyPress flag to determine if we've already
+ // handled the keydown event. #7269
+ // Unfortunately the code for & in keypress is the same as the up arrow,
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
+ // events when we know the keydown event was used to modify the
+ // search term. #7799
suppressKeyPress,
+ suppressKeyPressRepeat,
suppressInput;
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
@@ -66,11 +74,13 @@ $.widget( "ui.autocomplete", {
if ( self.options.disabled || self.element.prop( "readOnly" ) ) {
suppressKeyPress = true;
suppressInput = true;
+ suppressKeyPressRepeat = true;
return;
}
suppressKeyPress = false;
suppressInput = false;
+ suppressKeyPressRepeat = false;
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
@@ -116,6 +126,7 @@ $.widget( "ui.autocomplete", {
}
break;
default:
+ suppressKeyPressRepeat = true;
// search timeout should be triggered before the input value is changed
self._searchTimeout( event );
break;
@@ -127,6 +138,9 @@ $.widget( "ui.autocomplete", {
event.preventDefault();
return;
}
+ if ( suppressKeyPressRepeat ) {
+ return;
+ }
// replicate some key handlers to allow them to repeat in Firefox and Opera
var keyCode = $.ui.keyCode;