Skip to content

Commit ed07f0a

Browse files
committed
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.
1 parent 85b8816 commit ed07f0a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ui/jquery.ui.autocomplete.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ $.widget( "ui.autocomplete", {
153153
self.selectedItem = item;
154154
},
155155
blur: function( event, ui ) {
156-
if ( self.menu.element.is(":visible") ) {
156+
// don't set the value of the text field if it's already correct
157+
// this prevents moving the cursor unnecessarily
158+
if ( self.menu.element.is(":visible") &&
159+
( self.element.val() !== self.term ) ) {
157160
self.element.val( self.term );
158161
}
159162
}

0 commit comments

Comments
 (0)