diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2014-08-16 09:44:05 -0400 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2014-08-17 14:13:20 -0400 |
commit | d10440fe44c840dd5c69c4efb1c06d2636fa11c6 (patch) | |
tree | 5edee39d36d1c1566b69553da6083b9298738b5a /ui | |
parent | 075421d6d965c66055e47cde477f0ce2e23f1755 (diff) | |
download | jquery-ui-d10440fe44c840dd5c69c4efb1c06d2636fa11c6.tar.gz jquery-ui-d10440fe44c840dd5c69c4efb1c06d2636fa11c6.zip |
Draggable: Only focus the draggable if the event occurs on a handle
Refs #10527
Diffstat (limited to 'ui')
-rw-r--r-- | ui/draggable.js | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/ui/draggable.js b/ui/draggable.js index 3cae40f11..98f065efb 100644 --- a/ui/draggable.js +++ b/ui/draggable.js @@ -123,9 +123,14 @@ $.widget("ui.draggable", $.ui.mouse, { }, - _blurActiveElement: function() { + _blurActiveElement: function( event ) { var document = this.document[ 0 ]; + // Only need to blur if the event occurred on the draggable itself, see #10527 + if ( !this.handleElement.is( event.target ) ) { + return; + } + // support: IE9 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> try { @@ -134,12 +139,8 @@ $.widget("ui.draggable", $.ui.mouse, { // If the <body> is blurred, IE will switch windows, see #9520 if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) { - // Only need to blur if the event occurred on the draggable, see #10527 - if ( this.handleElement.is( event.target ) ) { - - // Blur any element that currently has focus, see #4261 - $( document.activeElement ).blur(); - } + // Blur any element that currently has focus, see #4261 + $( document.activeElement ).blur(); } } catch ( error ) {} }, @@ -289,7 +290,7 @@ $.widget("ui.draggable", $.ui.mouse, { return false; }, - _mouseUp: function(event) { + _mouseUp: function( event ) { //Remove frame helpers $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); @@ -300,8 +301,11 @@ $.widget("ui.draggable", $.ui.mouse, { $.ui.ddmanager.dragStop(this, event); } - // The interaction is over; whether or not the click resulted in a drag, focus the element - this.element.focus(); + // Only need to focus if the event occurred on the draggable itself, see #10527 + if ( this.handleElement.is( event.target ) ) { + // The interaction is over; whether or not the click resulted in a drag, focus the element + this.element.focus(); + } return $.ui.mouse.prototype._mouseUp.call(this, event); }, |