r3097 committed - autocomplete: Fix to set hasFocus on keypress; fixes the issue where t...

r3097 committed - autocomplete: Fix to set hasFocus on keypress; fixes the issue where t...


Revision: 3097
Author: joern.zaefferer
Date: Thu Aug 20 12:26:53 2009
Log: autocomplete: Fix to set hasFocus on keypress; fixes the issue where
the input already had focus before the autocomplete was applied
http://code.google.com/p/jquery-ui/source/detail?r=3097
Modified:
/branches/dev/autocomplete/ui/ui.autocomplete.js
=======================================
--- /branches/dev/autocomplete/ui/ui.autocomplete.js    Thu Aug 20 11:37:48
2009
+++ /branches/dev/autocomplete/ui/ui.autocomplete.js    Thu Aug 20 12:26:53
2009
@@ -58,6 +58,9 @@
        // TODO verify
        // only opera doesn't trigger keydown multiple times while pressed,
others don't work with keypress at all
        $input.bind(($.browser.opera ? "keypress" : "keydown")
+ ".autocomplete", function(event) {
+            // a keypress means the input has focus
+            // avoids issue where input had focus before the autocomplete was
applied
+            hasFocus = 1;
            // track last key pressed
            lastKeyPressCode = event.keyCode;
            switch(event.keyCode) {