diff options
-rw-r--r-- | tests/unit/autocomplete/autocomplete_core.js | 26 | ||||
-rw-r--r-- | ui/autocomplete.js | 6 |
2 files changed, 31 insertions, 1 deletions
diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index 961aca400..81d534cb8 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -163,6 +163,32 @@ test( "allow form submit on enter when menu is not active", function() { } })(); +asyncTest( "past end of menu in multiline autocomplete", function() { + expect( 2 ); + + var customVal = "custom value", + element = $( "#autocomplete-contenteditable" ).autocomplete({ + delay: 0, + source: [ "javascript" ], + focus: function( event, ui ) { + equal( ui.item.value, "javascript", "Item gained focus" ); + $( this ).text( customVal ); + event.preventDefault(); + } + }); + + element + .simulate( "focus" ) + .autocomplete( "search", "ja" ); + + setTimeout(function() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal( element.text(), customVal ); + start(); + }, 50 ); +}); + asyncTest( "handle race condition", function() { expect( 3 ); var count = 0, diff --git a/ui/autocomplete.js b/ui/autocomplete.js index c20ebf21a..30a539e51 100644 --- a/ui/autocomplete.js +++ b/ui/autocomplete.js @@ -545,7 +545,11 @@ $.widget( "ui.autocomplete", { } if ( this.menu.isFirstItem() && /^previous/.test( direction ) || this.menu.isLastItem() && /^next/.test( direction ) ) { - this._value( this.term ); + + if ( !this.isMultiLine ) { + this._value( this.term ); + } + this.menu.blur(); return; } |