Skip to content

Commit 82df692

Browse files
committed
Effects: Backporting 8108ec8 - Fixes #7595 - Wrapper-creating jquery-ui animations will discard any focus state during the animation - Thanks @rubyruy
1 parent 4c57f36 commit 82df692

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

ui/jquery.effects.core.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,16 @@ $.extend($.effects, {
367367
border: 'none',
368368
margin: 0,
369369
padding: 0
370-
});
370+
}),
371+
active = document.activeElement;
371372

372373
element.wrap(wrapper);
374+
375+
// Fixes #7595 - Elements lose focus when wrapped.
376+
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
377+
$( active ).focus();
378+
}
379+
373380
wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
374381

375382
// transfer positioning properties to the wrapper
@@ -394,8 +401,18 @@ $.extend($.effects, {
394401
},
395402

396403
removeWrapper: function(element) {
397-
if (element.parent().is('.ui-effects-wrapper'))
398-
return element.parent().replaceWith(element);
404+
var parent,
405+
active = document.activeElement;
406+
407+
if (element.parent().is('.ui-effects-wrapper')) {
408+
parent = element.parent().replaceWith(element);
409+
// Fixes #7595 - Elements lose focus when wrapped.
410+
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
411+
$( active ).focus();
412+
}
413+
return parent;
414+
}
415+
399416
return element;
400417
},
401418

0 commit comments

Comments
 (0)