]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: ESCAPE should not change content of a MultiLine
authorYermo Lamers <yml@yml.com>
Tue, 4 Feb 2014 21:47:26 +0000 (16:47 -0500)
committerScott González <scott.gonzalez@gmail.com>
Thu, 24 Jul 2014 21:00:55 +0000 (17:00 -0400)
Fixes #9790
Closes gh-1190

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

index c306495f20cf0cacd08b96fa133ef568504b3d76..e8a3e59378491d0606cb56de6e18e43b7dee10ef 100644 (file)
@@ -189,6 +189,34 @@ asyncTest( "past end of menu in multiline autocomplete", function() {
        }, 50 );
 });
 
+asyncTest( "ESCAPE 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.ESCAPE } );
+                equal( element.text(), customVal );
+                start();
+        }, 50 );
+});
+
+
+
 asyncTest( "handle race condition", function() {
        expect( 3 );
        var count = 0,
index d53a1d5e3553f146f70b5d9a7580daba8c83527c..3f428ea3db58112cee77c3c811f72e1f7eec558c 100644 (file)
@@ -130,7 +130,9 @@ $.widget( "ui.autocomplete", {
                                        break;
                                case keyCode.ESCAPE:
                                        if ( this.menu.element.is( ":visible" ) ) {
-                                               this._value( this.term );
+                                               if ( !this.isMultiLine ) {
+                                                       this._value( this.term );
+                                               }
                                                this.close( event );
                                                // Different browsers have different default behavior for escape
                                                // Single press can mean undo or clear