From 63c103dd540897c9df0c064da36e5cf40b824518 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 5 May 2015 09:29:21 -0400 Subject: Draggable: Improve detection for when to blur the active element Fixes #12472 Fixes #14905 Closes gh-1548 --- ui/widgets/draggable.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/widgets/draggable.js b/ui/widgets/draggable.js index 7da09b7ec..32bf861ed 100644 --- a/ui/widgets/draggable.js +++ b/ui/widgets/draggable.js @@ -143,14 +143,19 @@ $.widget( "ui.draggable", $.ui.mouse, { }, _blurActiveElement: function( event ) { - - // Only need to blur if the event occurred on the draggable itself, see #10527 - if ( !this.handleElement.is( event.target ) ) { + var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ), + target = $( event.target ); + + // Only blur if the event occurred on an element that is: + // 1) within the draggable handle + // 2) but not within the currently focused element + // See #10527, #12472 + if ( this._getHandle( event ) && target.closest( activeElement ).length ) { return; } // Blur any element that currently has focus, see #4261 - $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) ); + $.ui.safeBlur( activeElement ); }, _mouseStart: function( event ) { -- cgit v1.2.3