aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/autocomplete/core.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-10-15 10:11:14 -0400
committerScott González <scott.gonzalez@gmail.com>2015-10-16 14:09:05 -0400
commit548fbf570caa5fdee973bbbe8ac2d36b0338c2b9 (patch)
tree4d3dc28cd3084f62726b461855a156fb4d9aa46a /tests/unit/autocomplete/core.js
parent7df2f1905a1ec4727f00451f8d794aeb35ec4159 (diff)
downloadjquery-ui-548fbf570caa5fdee973bbbe8ac2d36b0338c2b9.tar.gz
jquery-ui-548fbf570caa5fdee973bbbe8ac2d36b0338c2b9.zip
Autocomplete: Close the menu on any outside interactions
This ensures that the menu will close if the user interacts with a draggable, resizable, etc. element since those interactions don't change focus. Ref #6642 Closes gh-1614
Diffstat (limited to 'tests/unit/autocomplete/core.js')
-rw-r--r--tests/unit/autocomplete/core.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/autocomplete/core.js b/tests/unit/autocomplete/core.js
index 41be5ae6a..9cfac3917 100644
--- a/tests/unit/autocomplete/core.js
+++ b/tests/unit/autocomplete/core.js
@@ -398,4 +398,28 @@ asyncTest( "Search if the user retypes the same value (#7434)", function() {
} );
} );
+asyncTest( "Close on click outside when focus remains", function() {
+ expect( 2 );
+
+ var element = $( "#autocomplete" ).autocomplete( {
+ source: [ "java", "javascript" ],
+ delay: 0
+ } );
+ var menu = element.autocomplete( "widget" );
+
+ $( "body" ).on( "mousedown", function( event ) {
+ event.preventDefault();
+ } );
+
+ element.val( "j" ).autocomplete( "search", "j" );
+ setTimeout(function() {
+ ok( menu.is( ":visible" ), "menu displays initially" );
+ $( "body" ).simulate( "mousedown" );
+ setTimeout(function() {
+ ok( menu.is( ":hidden" ), "menu closes after clicking elsewhere" );
+ start();
+ } );
+ } );
+} );
+
} );