From 548fbf570caa5fdee973bbbe8ac2d36b0338c2b9 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 15 Oct 2015 10:11:14 -0400 Subject: 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 --- tests/unit/autocomplete/core.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/unit/autocomplete/core.js') 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(); + } ); + } ); +} ); + } ); -- cgit v1.2.3