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 192192 container . children ( '.' + selected ) . removeClass ( selected ) ;
193193 } ) ;
194194
195-
196195 // Listen for click event on suggestions list:
197196 container . on ( 'click.autocomplete' , suggestionSelector , function ( ) {
198197 that . select ( $ ( this ) . data ( 'index' ) ) ;
457456 } ,
458457
459458 onValueChange : function ( ) {
459+ if ( this . ignoreValueChange ) {
460+ this . ignoreValueChange = false ;
461+ return ;
462+ }
463+
460464 var that = this ,
461465 options = that . options ,
462466 value = that . el . val ( ) ,
856860 if ( that . selectedIndex === 0 ) {
857861 $ ( that . suggestionsContainer ) . children ( ) . first ( ) . removeClass ( that . classes . selected ) ;
858862 that . selectedIndex = - 1 ;
863+ that . ignoreValueChange = false ;
859864 that . el . val ( that . currentValue ) ;
860865 that . findBestHint ( ) ;
861866 return ;
898903 }
899904
900905 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 ;
901911 that . el . val ( that . getValue ( that . suggestions [ index ] . value ) ) ;
902912 }
913+
903914 that . signalHint ( null ) ;
904915 } ,
905916
You can’t perform that action at this time.
0 commit comments