github github
  • Home
  • Pricing and Signup
  • Training
  • Gist
  • Blog
  • Login

jquery / jquery-ui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 919
    • 211
  • Source
  • Commits
  • Network (211)
  • Graphs
  • Tree: de266a1

click here to add a description

click here to add a homepage

  • Switch Branches (8)
    • bind
    • devpreview
    • formcontrols
    • master
    • menu
    • panel
    • tooltip
    • widget-super
  • Switch Tags (21)
    • 1.9m2
    • 1.9m1
    • 1.8rc3
    • 1.8rc2
    • 1.8rc1
    • 1.8b1
    • 1.8a2
    • 1.8a1
    • 1.8.4
    • 1.8.3
    • 1.8.2
    • 1.8.1
    • 1.8
    • 1.7
    • 1.6rc6
    • 1.6rc5
    • 1.6rc3
    • 1.6rc2
    • 1.6
    • 1.5.2
    • 1.5.1
  • Comments
  • Contributors
Sending Request…

The official jQuery user interface library. — Read more

  Cancel

http://jqueryui.com/

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

Autocomplete: Handle clicks outside the autocomplete after scrolling the results (which causes the body to gain focus). Fixes #5903 - Autocomplete doesn't close after scrolling.
scottgonzalez (author)
Thu Aug 05 05:51:54 -0700 2010
commit  de266a1275efa405eb71
tree    d2f0da9cbecaf229d137
parent  ed07f0a05656d2c66db4
M ui/jquery.ui.autocomplete.js 19 ••••
Txt ui/jquery.ui.autocomplete.js
  • View file @ de266a1
... ...
@@ -119,7 +119,24 @@ $.widget( "ui.autocomplete", {
119 119
       .addClass( "ui-autocomplete" )
120 120
       .appendTo( $( this.options.appendTo || "body", doc )[0] )
121 121
       // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
122  
-      .mousedown(function() {
  122
+      .mousedown(function( event ) {
  123
+        // clicking on the scrollbar causes focus to shift to the body
  124
+        // but we can't detect a mouseup or a click immediately afterward
  125
+        // so we have to track the next mousedown and close the menu if
  126
+        // the user clicks somewhere outside of the autocomplete
  127
+        var menuElement = self.menu.element[ 0 ];
  128
+        if ( event.target === menuElement ) {
  129
+          setTimeout(function() {
  130
+            $( document ).one( 'mousedown', function( event ) {
  131
+              if ( event.target !== self.element[ 0 ] &&
  132
+                event.target !== menuElement &&
  133
+                !$.ui.contains( menuElement, event.target ) ) {
  134
+                self.close();
  135
+              }
  136
+            });
  137
+          }, 1 );
  138
+        }
  139
+
123 140
         // use another timeout to make sure the blur-event-handler on the input was already triggered
124 141
         setTimeout(function() {
125 142
           clearTimeout( self.closing );

1 notes on commit de266a1

jzaefferer added a note to de266a1 repo collab

Thu Aug 05 06:27:05 -0700 2010

What an endless source of joy!

Please log in to comment.
Dedicated Server Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
  • Blog
  • Support
  • Training
  • Job Board
  • Shop
  • Contact
  • API
  • Status
  • © 2010 GitHub Inc. All rights reserved.
  • Terms of Service
  • Privacy
  • Security
  • English
  • Deutsch
  • Français
  • 日本語
  • Português (BR)
  • 中文
  • See all available languages

Your current locale selection: English. Choose another?

  • English
  • Afrikaans
  • Català
  • Čeština
  • Deutsch
  • Español
  • Français
  • Hrvatski
  • Indonesia
  • Italiano
  • 日本語
  • Nederlands
  • Norsk
  • Polski
  • Português (BR)
  • Српски
  • Svenska
  • 中文