aboutsummaryrefslogtreecommitdiffstats
path: root/ui/widgets/autocomplete.js
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2017-03-30 23:18:25 +0200
committerFelix Nagel <info@felixnagel.com>2017-03-30 23:18:25 +0200
commit4267e4283ca6259d5e7612c8dd66024f766b1595 (patch)
treece0cd1a7ae42d6f7a3c09c887dc2a0a16629b73d /ui/widgets/autocomplete.js
parent188550faff8baefff96e36b4094ad7fd00c91c45 (diff)
parent032ddc3349f625e0840aa8e266b5d8ebee994853 (diff)
downloadjquery-ui-4267e4283ca6259d5e7612c8dd66024f766b1595.tar.gz
jquery-ui-4267e4283ca6259d5e7612c8dd66024f766b1595.zip
Merge branch 'master' into datepicker
# Conflicts: # ui/i18n/datepicker-sv.js # ui/widgets/datepicker.js
Diffstat (limited to 'ui/widgets/autocomplete.js')
-rw-r--r--ui/widgets/autocomplete.js34
1 files changed, 11 insertions, 23 deletions
diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js
index 079b0dab0..c5bddc074 100644
--- a/ui/widgets/autocomplete.js
+++ b/ui/widgets/autocomplete.js
@@ -200,11 +200,6 @@ $.widget( "ui.autocomplete", {
this.previous = this._value();
},
blur: function( event ) {
- if ( this.cancelBlur ) {
- delete this.cancelBlur;
- return;
- }
-
clearTimeout( this.searching );
this.close( event );
this._change( event );
@@ -220,31 +215,24 @@ $.widget( "ui.autocomplete", {
role: null
} )
.hide()
+
+ // Support: IE 11 only, Edge <= 14
+ // For other browsers, we preventDefault() on the mousedown event
+ // to keep the dropdown from taking focus from the input. This doesn't
+ // work for IE/Edge, causing problems with selection and scrolling (#9638)
+ // Happily, IE and Edge support an "unselectable" attribute that
+ // prevents an element from receiving focus, exactly what we want here.
+ .attr( {
+ "unselectable": "on"
+ } )
.menu( "instance" );
this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
this._on( this.menu.element, {
mousedown: function( event ) {
- // prevent moving focus out of the text field
+ // Prevent moving focus out of the text field
event.preventDefault();
-
- // IE doesn't prevent moving focus even with event.preventDefault()
- // so we set a flag to know when we should ignore the blur event
- 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.trigger( "focus" );
- }
- } );
},
menufocus: function( event, ui ) {
var label, item;