@@ -94,20 +94,9 @@ $.widget("ui.draggable", $.ui.mouse, {
9494 } ,
9595
9696 _mouseCapture : function ( event ) {
97+ var o = this . options ;
9798
98- var document = this . document [ 0 ] ,
99- o = this . options ;
100-
101- // support: IE9
102- // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
103- try {
104- // Support: IE9+
105- // If the <body> is blurred, IE will switch windows, see #9520
106- if ( document . activeElement && document . activeElement . nodeName . toLowerCase ( ) !== "body" ) {
107- // Blur any element that currently has focus, see #4261
108- $ ( document . activeElement ) . blur ( ) ;
109- }
110- } catch ( error ) { }
99+ this . _blurActiveElement ( event ) ;
111100
112101 // among others, prevent a drag on a resizable-handle
113102 if ( this . helper || o . disabled || $ ( event . target ) . closest ( ".ui-resizable-handle" ) . length > 0 ) {
@@ -134,6 +123,27 @@ $.widget("ui.draggable", $.ui.mouse, {
134123
135124 } ,
136125
126+ _blurActiveElement : function ( ) {
127+ var document = this . document [ 0 ] ;
128+
129+ // support: IE9
130+ // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
131+ try {
132+
133+ // Support: IE9, IE10
134+ // If the <body> is blurred, IE will switch windows, see #9520
135+ if ( document . activeElement && document . activeElement . nodeName . toLowerCase ( ) !== "body" ) {
136+
137+ // Only need to blur if the event occurred on the draggable, see #10527
138+ if ( this . handleElement . is ( event . target ) ) {
139+
140+ // Blur any element that currently has focus, see #4261
141+ $ ( document . activeElement ) . blur ( ) ;
142+ }
143+ }
144+ } catch ( error ) { }
145+ } ,
146+
137147 _mouseStart : function ( event ) {
138148
139149 var o = this . options ;
0 commit comments