]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Don't reset text field value on blur unless it will actually change...
authorScott González <scott.gonzalez@gmail.com>
Wed, 4 Aug 2010 17:26:42 +0000 (13:26 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 4 Aug 2010 17:26:42 +0000 (13:26 -0400)
ui/jquery.ui.autocomplete.js

index 75dfdc747c89132d22df40188a65130dfa05b43d..98130ab502bb4050b4d0963b3ad78f7b6882ec0e 100644 (file)
@@ -153,7 +153,10 @@ $.widget( "ui.autocomplete", {
                                        self.selectedItem = item;
                                },
                                blur: function( event, ui ) {
-                                       if ( self.menu.element.is(":visible") ) {
+                                       // don't set the value of the text field if it's already correct
+                                       // this prevents moving the cursor unnecessarily
+                                       if ( self.menu.element.is(":visible") &&
+                                               ( self.element.val() !== self.term ) ) {
                                                self.element.val( self.term );
                                        }
                                }