File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 192
192
container . children ( '.' + selected ) . removeClass ( selected ) ;
193
193
} ) ;
194
194
195
-
196
195
// Listen for click event on suggestions list:
197
196
container . on ( 'click.autocomplete' , suggestionSelector , function ( ) {
198
197
that . select ( $ ( this ) . data ( 'index' ) ) ;
457
456
} ,
458
457
459
458
onValueChange : function ( ) {
459
+ if ( this . ignoreValueChange ) {
460
+ this . ignoreValueChange = false ;
461
+ return ;
462
+ }
463
+
460
464
var that = this ,
461
465
options = that . options ,
462
466
value = that . el . val ( ) ,
856
860
if ( that . selectedIndex === 0 ) {
857
861
$ ( that . suggestionsContainer ) . children ( ) . first ( ) . removeClass ( that . classes . selected ) ;
858
862
that . selectedIndex = - 1 ;
863
+ that . ignoreValueChange = false ;
859
864
that . el . val ( that . currentValue ) ;
860
865
that . findBestHint ( ) ;
861
866
return ;
898
903
}
899
904
900
905
if ( ! that . options . preserveInput ) {
906
+ // During onBlur event, browser will trigger "change" event,
907
+ // because value has changed, to avoid side effect ignore,
908
+ // that event, so that correct suggestion can be selected
909
+ // when clicking on suggestion with a mouse
910
+ that . ignoreValueChange = true ;
901
911
that . el . val ( that . getValue ( that . suggestions [ index ] . value ) ) ;
902
912
}
913
+
903
914
that . signalHint ( null ) ;
904
915
} ,
905
916
You can’t perform that action at this time.
0 commit comments