@@ -48,7 +48,15 @@ $.widget( "ui.autocomplete", {
48
48
_create : function ( ) {
49
49
var self = this ,
50
50
doc = this . element [ 0 ] . ownerDocument ,
51
+ // Some browsers only repeat keydown events, not keypress events,
52
+ // so we use the suppressKeyPress flag to determine if we've already
53
+ // handled the keydown event. #7269
54
+ // Unfortunately the code for & in keypress is the same as the up arrow,
55
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
56
+ // events when we know the keydown event was used to modify the
57
+ // search term. #7799
51
58
suppressKeyPress ,
59
+ suppressKeyPressRepeat ,
52
60
suppressInput ;
53
61
54
62
this . valueMethod = this . element [ this . element . is ( "input,textarea" ) ? "val" : "text" ] ;
@@ -66,11 +74,13 @@ $.widget( "ui.autocomplete", {
66
74
if ( self . options . disabled || self . element . prop ( "readOnly" ) ) {
67
75
suppressKeyPress = true ;
68
76
suppressInput = true ;
77
+ suppressKeyPressRepeat = true ;
69
78
return ;
70
79
}
71
80
72
81
suppressKeyPress = false ;
73
82
suppressInput = false ;
83
+ suppressKeyPressRepeat = false ;
74
84
var keyCode = $ . ui . keyCode ;
75
85
switch ( event . keyCode ) {
76
86
case keyCode . PAGE_UP :
@@ -116,6 +126,7 @@ $.widget( "ui.autocomplete", {
116
126
}
117
127
break ;
118
128
default :
129
+ suppressKeyPressRepeat = true ;
119
130
// search timeout should be triggered before the input value is changed
120
131
self . _searchTimeout ( event ) ;
121
132
break ;
@@ -127,6 +138,9 @@ $.widget( "ui.autocomplete", {
127
138
event . preventDefault ( ) ;
128
139
return ;
129
140
}
141
+ if ( suppressKeyPressRepeat ) {
142
+ return ;
143
+ }
130
144
131
145
// replicate some key handlers to allow them to repeat in Firefox and Opera
132
146
var keyCode = $ . ui . keyCode ;
0 commit comments