Skip to content

Commit 581bfb5

Browse files
committed
Autocomplete: Restore focus after clicking a menu item, if necessary
Fixes #9201 Closes gh-1470
1 parent f330278 commit 581bfb5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ui/autocomplete.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ $.widget( "ui.autocomplete", {
229229
this.cancelBlur = true;
230230
this._delay(function() {
231231
delete this.cancelBlur;
232+
233+
// Support: IE 8 only
234+
// Right clicking a menu item or selecting text from the menu items will
235+
// result in focus moving out of the input. However, we've already received
236+
// and ignored the blur event because of the cancelBlur flag set above. So
237+
// we restore focus to ensure that the menu closes properly based on the user's
238+
// next actions.
239+
if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
240+
this.element.focus();
241+
}
232242
});
233243

234244
// clicking on the scrollbar causes focus to shift to the body

0 commit comments

Comments
 (0)