]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Do not set value on multi-line input
authorYermo <yml@yml.com>
Sat, 25 Jan 2014 22:39:27 +0000 (17:39 -0500)
committerScott González <scott.gonzalez@gmail.com>
Tue, 28 Jan 2014 17:35:16 +0000 (12:35 -0500)
This fixes an issue where contenteditable text was getting overwritten when
wrapping past the bottom or top of the autocomplete menu.

Fixes #9771
Closes gh-1184

tests/unit/autocomplete/autocomplete_core.js
ui/autocomplete.js

index 961aca40028cf45389176a8b9f7e9ed395786efb..81d534cb80043f17ca9d5d6c02acf29e9265da75 100644 (file)
@@ -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,
index c20ebf21abffb303aaa47fcd07a481443dab2a34..30a539e5154e8a86fb08b3b3c10bcea90a564aad 100644 (file)
@@ -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;
                }