diff options
author | Corey Frang <gnarf@gnarf.net> | 2011-08-02 16:58:52 -0500 |
---|---|---|
committer | Corey Frang <gnarf@gnarf.net> | 2011-08-02 16:58:52 -0500 |
commit | 82df6924cbb0fa080590d83b4edc6183dd05ce93 (patch) | |
tree | d36da6857fd235c500f3b60e1bfa6aabd4160faa | |
parent | 4c57f361ada4a23d6a42a099604549753ea8fe6c (diff) | |
download | jquery-ui-82df6924cbb0fa080590d83b4edc6183dd05ce93.tar.gz jquery-ui-82df6924cbb0fa080590d83b4edc6183dd05ce93.zip |
Effects: Backporting 8108ec8 - Fixes #7595 - Wrapper-creating jquery-ui animations will discard any focus state during the animation - Thanks @rubyruy
-rw-r--r-- | ui/jquery.effects.core.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 46627158e..156bfdf32 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -367,9 +367,16 @@ $.extend($.effects, { border: 'none', margin: 0, padding: 0 - }); + }), + active = document.activeElement; element.wrap(wrapper); + + // Fixes #7595 - Elements lose focus when wrapped. + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { + $( active ).focus(); + } + wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element // transfer positioning properties to the wrapper @@ -394,8 +401,18 @@ $.extend($.effects, { }, removeWrapper: function(element) { - if (element.parent().is('.ui-effects-wrapper')) - return element.parent().replaceWith(element); + var parent, + active = document.activeElement; + + if (element.parent().is('.ui-effects-wrapper')) { + parent = element.parent().replaceWith(element); + // Fixes #7595 - Elements lose focus when wrapped. + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { + $( active ).focus(); + } + return parent; + } + return element; }, |