aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-03-06 16:30:17 -0500
committerScott González <scott.gonzalez@gmail.com>2015-03-12 11:28:09 -0400
commit581bfb55bf4f4f614a6e0c0ac545cf1aa7d29d0a (patch)
treef88ddbe256607f9358a320ab1a5843d2f2f63b23
parentf33027840cdac5152599da66635981bbe68c6bda (diff)
downloadjquery-ui-581bfb55bf4f4f614a6e0c0ac545cf1aa7d29d0a.tar.gz
jquery-ui-581bfb55bf4f4f614a6e0c0ac545cf1aa7d29d0a.zip
Autocomplete: Restore focus after clicking a menu item, if necessary
Fixes #9201 Closes gh-1470
-rw-r--r--ui/autocomplete.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/ui/autocomplete.js b/ui/autocomplete.js
index 399a190b5..3a52e1b17 100644
--- a/ui/autocomplete.js
+++ b/ui/autocomplete.js
@@ -229,6 +229,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