From: Scott González Date: Fri, 6 Mar 2015 21:30:17 +0000 (-0500) Subject: Autocomplete: Restore focus after clicking a menu item, if necessary X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9ac18234e1a2755a91e0d2fc2206e9b50e324ced;p=jquery-ui.git Autocomplete: Restore focus after clicking a menu item, if necessary Fixes #9201 Closes gh-1470 (cherry picked from commit 581bfb55bf4f4f614a6e0c0ac545cf1aa7d29d0a) --- diff --git a/ui/autocomplete.js b/ui/autocomplete.js index 6e477bb41..e4f998faa 100644 --- a/ui/autocomplete.js +++ b/ui/autocomplete.js @@ -221,6 +221,16 @@ $.widget( "ui.autocomplete", { this.cancelBlur = true; this._delay(function() { delete this.cancelBlur; + + // Support: IE 8 only + // Right clicking a menu item or selecting text from the menu items will + // result in focus moving out of the input. However, we've already received + // and ignored the blur event because of the cancelBlur flag set above. So + // we restore focus to ensure that the menu closes properly based on the user's + // next actions. + if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { + this.element.focus(); + } }); // clicking on the scrollbar causes focus to shift to the body