Permalink
Browse files

Autocomplete: Handle IE firing focus events asynchronously. Fixes #61…

…09 - Autocomplete Change event does not fire in IE.
  • Loading branch information...
scottgonzalez committed Sep 24, 2010
1 parent a3da104 commit 0ccc78698b55d5e1bc336bb754b546a9ad19ea5c
Showing with 6 additions and 0 deletions.
  1. +6 −0 ui/jquery.ui.autocomplete.js
@@ -160,6 +160,12 @@ $.widget( "ui.autocomplete", {
if ( self.element[0] !== doc.activeElement ) {
self.element.focus();
self.previous = previous;
// #6109 - IE triggers two focus events and the second
// is asynchronous, so we need to reset the previous
// term synchronously and asynchronously :-(
setTimeout(function() {
self.previous = previous;
}, 1);
}
if ( false !== self._trigger( "select", event, { item: item } ) ) {

2 comments on commit 0ccc786

@jzaefferer

This comment has been minimized.

Member

jzaefferer replied Sep 26, 2010

Bahhh. Is it on purpose that self.previous get sets twice? Or should line 162 be removed?

@scottgonzalez

This comment has been minimized.

Member

scottgonzalez replied Sep 27, 2010

Yes, that was intentional. I wasn't sure if there would be any problems not setting it immediately. It's possible that only setting it asynchronously would be fine, but I didn't try to walk through all the possible use cases so I just set it twice.

Please sign in to comment.