Skip to content

Commit 9ac1823

Browse files
committed
Autocomplete: Restore focus after clicking a menu item, if necessary
Fixes #9201 Closes gh-1470 (cherry picked from commit 581bfb5)
1 parent 2256eed commit 9ac1823

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
@@ -221,6 +221,16 @@ $.widget( "ui.autocomplete", {
221221
this.cancelBlur = true;
222222
this._delay(function() {
223223
delete this.cancelBlur;
224+
225+
// Support: IE 8 only
226+
// Right clicking a menu item or selecting text from the menu items will
227+
// result in focus moving out of the input. However, we've already received
228+
// and ignored the blur event because of the cancelBlur flag set above. So
229+
// we restore focus to ensure that the menu closes properly based on the user's
230+
// next actions.
231+
if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
232+
this.element.focus();
233+
}
224234
});
225235

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

0 commit comments

Comments
 (0)