File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -338,4 +338,25 @@ test( ".replaceWith() (#9172)", function() {
338
338
equal ( parent . html ( ) . toLowerCase ( ) , replacement ) ;
339
339
} ) ;
340
340
341
+ asyncTest ( "Search if the user retypes the same value (#7434)" , function ( ) {
342
+ expect ( 3 ) ;
343
+ var element = $ ( "#autocomplete" ) . autocomplete ( {
344
+ source : [ "java" , "javascript" ] ,
345
+ delay : 0
346
+ } ) ,
347
+ menu = element . autocomplete ( "instance" ) . menu . element ;
348
+
349
+ element . val ( "j" ) . simulate ( "keydown" ) ;
350
+ setTimeout ( function ( ) {
351
+ ok ( menu . is ( ":visible" ) , "menu displays initially" ) ;
352
+ element . trigger ( "blur" ) ;
353
+ ok ( ! menu . is ( ":visible" ) , "menu hidden after blur" ) ;
354
+ element . val ( "j" ) . simulate ( "keydown" ) ;
355
+ setTimeout ( function ( ) {
356
+ ok ( menu . is ( ":visible" ) , "menu displays after typing the same value" ) ;
357
+ start ( ) ;
358
+ } ) ;
359
+ } ) ;
360
+ } ) ;
361
+
341
362
} ( jQuery ) ) ;
Original file line number Diff line number Diff line change @@ -394,8 +394,13 @@ $.widget( "ui.autocomplete", {
394
394
_searchTimeout : function ( event ) {
395
395
clearTimeout ( this . searching ) ;
396
396
this . searching = this . _delay ( function ( ) {
397
- // only search if the value has changed
398
- if ( this . term !== this . _value ( ) ) {
397
+
398
+ // Search if the value has changed, or if the user retypes the same value (see #7434)
399
+ var equalValues = this . term === this . _value ( ) ,
400
+ menuVisible = this . menu . element . is ( ":visible" ) ,
401
+ modifierKey = event . altKey || event . ctrlKey || event . metaKey || event . shiftKey ;
402
+
403
+ if ( ! equalValues || ( equalValues && ! menuVisible && ! modifierKey ) ) {
399
404
this . selectedItem = null ;
400
405
this . search ( null , event ) ;
401
406
}
You can’t perform that action at this time.
0 commit comments