aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2010-05-18 14:57:02 +0200
committerjzaefferer <joern.zaefferer@gmail.com>2010-05-18 14:57:02 +0200
commitfc093e9feb4450b1ab93e3da9a2f7abb1d4335b5 (patch)
treeafb3ccfb589f0f92f095296904a1bf18f7398aa1 /ui
parentfcbf4c0872cfc0b0c9fa9e6808ff0654e4decd98 (diff)
downloadjquery-ui-fc093e9feb4450b1ab93e3da9a2f7abb1d4335b5.tar.gz
jquery-ui-fc093e9feb4450b1ab93e3da9a2f7abb1d4335b5.zip
Prevent autocomplete-menu from closing when clicking 'slowly', eg. a long mousedown. Fix for #5405 - Autocomplete: select event not triggered when mousedown duration > blur timeout
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.autocomplete.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 64c098aa0..bd7420df8 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -96,7 +96,6 @@ $.widget( "ui.autocomplete", {
.bind( "blur.autocomplete", function( event ) {
clearTimeout( self.searching );
// clicks on the menu (or a button to trigger a search) will cause a blur event
- // TODO try to implement this without a timeout, see clearTimeout in search()
self.closing = setTimeout(function() {
self.close( event );
self._change( event );
@@ -109,6 +108,13 @@ $.widget( "ui.autocomplete", {
this.menu = $( "<ul></ul>" )
.addClass( "ui-autocomplete" )
.appendTo( "body", doc )
+ // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
+ .mousedown(function() {
+ // use another timeout to make sure the blur-event-handler on the input was already triggered
+ setTimeout(function() {
+ clearTimeout( self.closing );
+ }, 13);
+ })
.menu({
focus: function( event, ui ) {
var item = ui.item.data( "item.autocomplete" );