From: Scott González Date: Wed, 4 Aug 2010 17:26:42 +0000 (-0400) Subject: Autocomplete: Don't reset text field value on blur unless it will actually change... X-Git-Tag: 1.8.4~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ed07f0a05656d2c66db453c8f6d664f69ec1a04d;p=jquery-ui.git Autocomplete: Don't reset text field value on blur unless it will actually change the value. Fixes #5900 - Autocomplete: mousing over menu option replaces text box contents, moves caret. --- diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 75dfdc747..98130ab50 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/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 ); } }