Skip to content

Commit

Permalink
Autocomplete: Handle IE firing focus events asynchronously. Fixes #61…
Browse files Browse the repository at this point in the history
…09 - Autocomplete Change event does not fire in IE.
  • Loading branch information
scottgonzalez committed Sep 24, 2010
1 parent a3da104 commit 0ccc786
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ui/jquery.ui.autocomplete.js
Expand Up @@ -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 } ) ) {
Expand Down

2 comments on commit 0ccc786

@jzaefferer
Copy link
Member

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

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.