Skip to main content

Search and Top Navigation

#8421 closed bug (duplicate)

Opened July 03, 2012 10:18AM UTC

Closed July 03, 2012 02:38PM UTC

Last modified July 03, 2012 02:38PM UTC

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).

Attachments (0)
Change History (4)

Changed July 03, 2012 01:35PM UTC by scottgonzalez comment:1

owner: → 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?

Changed July 03, 2012 02:33PM UTC by jaiew comment:2

status: pendingnew

Thanks that's resolved the issue.

Changed July 03, 2012 02:38PM UTC by scottgonzalez comment:3

resolution: → duplicate
status: newclosed

Great :-)

Changed July 03, 2012 02:38PM UTC by scottgonzalez comment:4

Duplicate of #7742.