Skip to content
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 1 changed file with 6 additions and 0 deletions.
@@ -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
Copy link
Member

@jzaefferer jzaefferer commented on 0ccc786 Sep 26, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@scottgonzalez
Copy link
Member Author

@scottgonzalez scottgonzalez commented on 0ccc786 Sep 27, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.