mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Draggable: Only blur the focused element if the event occurs on a handle
Fixes #10527
This commit is contained in:
parent
b5846bece3
commit
075421d6d9
@ -94,20 +94,9 @@ $.widget("ui.draggable", $.ui.mouse, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_mouseCapture: function(event) {
|
_mouseCapture: function(event) {
|
||||||
|
var o = this.options;
|
||||||
|
|
||||||
var document = this.document[ 0 ],
|
this._blurActiveElement( event );
|
||||||
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 ) {}
|
|
||||||
|
|
||||||
// among others, prevent a drag on a resizable-handle
|
// among others, prevent a drag on a resizable-handle
|
||||||
if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
|
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) {
|
_mouseStart: function(event) {
|
||||||
|
|
||||||
var o = this.options;
|
var o = this.options;
|
||||||
|
Loading…
Reference in New Issue
Block a user