Browse files

Autocomplete: Don't reset text field value on blur unless it will act…

…ually change the value. Fixes #5900 - Autocomplete: mousing over menu option replaces text box contents, moves caret.
  • Loading branch information...
1 parent 85b8816 commit ed07f0a05656d2c66db453c8f6d664f69ec1a04d @scottgonzalez scottgonzalez committed Aug 4, 2010
Showing with 4 additions and 1 deletion.
  1. +4 −1 ui/jquery.ui.autocomplete.js
View
5 ui/jquery.ui.autocomplete.js
@@ -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 );
}
}

0 comments on commit ed07f0a

Please sign in to comment.