Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#8421 closed bug (duplicate)

autoFocus option on autocomplete changes value in input field

Reported by: jaiew Owned by: jaiew
Priority: minor Milestone: 1.9.0
Component: ui.autocomplete Version: 1.8.20
Keywords: Cc:
Blocked by: Blocking:


Operating system: OSX

Browser: Chrome 20.0.1132.47

If you set the autoFocus option to true on the autocomplete and using an ajax source then when typing into it the blur event on the menu fires and if the search term and the value in the input field are different then the value in the input field will be changed with the value of self.term.

This is the blur event defined on the for the autocomplete:

blur: function( event, ui ) {
 	// don't set the value of the text field if it's already correct
	// this prevents moving the cursor unnecessarily
	if (":visible") && ( self.element.val() !== self.term ) ) {
		self.element.val( self.term );

If you are typing in fast enough or even just trying to clear the input field by holding down delete the value in the input field can sometimes change to the old search term and not the new one.

eg. I was typing "Fitzroy crossing" but because of the bug the auto complete would sometimes change "Fitzroy cross" to "Fitzroy crss".

I've created an example on jsfiddle here:

The issue only seems to be an issue when using an ajax source so I'm using sinon to mock ajax responses in my example.

As stated before the bug is particularly noticeable if you hold down the delete key (On a mac).

Change History (4)

comment:1 Changed 11 years ago by Scott González

Owner: set to jaiew
Status: newpending

That behavior was changed 9 months ago, see #7742. Can you please test against and confirm whether you're still having a problem?

comment:2 Changed 11 years ago by jaiew

Status: pendingnew

Thanks that's resolved the issue.

comment:3 Changed 11 years ago by Scott González

Resolution: duplicate
Status: newclosed

Great :-)

comment:4 Changed 11 years ago by Scott González

Duplicate of #7742.

Note: See TracTickets for help on using tickets.