diff options
author | TJ VanToll <tj.vantoll@gmail.com> | 2014-08-15 11:09:19 -0400 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2014-08-17 14:13:20 -0400 |
commit | 075421d6d965c66055e47cde477f0ce2e23f1755 (patch) | |
tree | 83584f5fd25c8e09f2d6a0b23d3db90454d75d3c | |
parent | b5846bece34db31d69e75cb3a3537827c005910e (diff) | |
download | jquery-ui-075421d6d965c66055e47cde477f0ce2e23f1755.tar.gz jquery-ui-075421d6d965c66055e47cde477f0ce2e23f1755.zip |
Draggable: Only blur the focused element if the event occurs on a handle
Fixes #10527
-rw-r--r-- | ui/draggable.js | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/ui/draggable.js b/ui/draggable.js index 3e427babe..3cae40f11 100644 --- a/ui/draggable.js +++ b/ui/draggable.js @@ -94,20 +94,9 @@ $.widget("ui.draggable", $.ui.mouse, { }, _mouseCapture: function(event) { + var o = this.options; - var document = this.document[ 0 ], - o = this.options; - - // support: IE9 - // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> - try { - // Support: IE9+ - // If the <body> is blurred, IE will switch windows, see #9520 - if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) { - // Blur any element that currently has focus, see #4261 - $( document.activeElement ).blur(); - } - } catch ( error ) {} + this._blurActiveElement( event ); // among others, prevent a drag on a resizable-handle if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { @@ -134,6 +123,27 @@ $.widget("ui.draggable", $.ui.mouse, { }, + _blurActiveElement: function() { + var document = this.document[ 0 ]; + + // support: IE9 + // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> + try { + + // Support: IE9, IE10 + // 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(); + } + } + } catch ( error ) {} + }, + _mouseStart: function(event) { var o = this.options; |