diff options
author | Corey Frang <gnarf@gnarf.net> | 2011-08-02 16:54:24 -0500 |
---|---|---|
committer | Corey Frang <gnarf@gnarf.net> | 2011-08-02 16:54:24 -0500 |
commit | 8108ec82dbc1c203893db18aac827b93d48cfc07 (patch) | |
tree | ee11aa67dd2abe410361f53763766f1327361b19 /ui/jquery.effects.core.js | |
parent | 8fe87e288544204925265a4e7f19b7dfa24deed6 (diff) | |
download | jquery-ui-8108ec82dbc1c203893db18aac827b93d48cfc07.tar.gz jquery-ui-8108ec82dbc1c203893db18aac827b93d48cfc07.zip |
Effects: Adding a check to retain focused elements after wrapping and unwrapping in animations - Fixes #7595 - Wrapper-creating jquery-ui animations will discard any focus state during the animation - Thanks @rubyruy
Diffstat (limited to 'ui/jquery.effects.core.js')
-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 b08cd6cf4..15d81b4b0 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -415,9 +415,16 @@ $.extend( $.effects, { size = { width: element.width(), height: element.height() - }; + }, + 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 @@ -449,8 +456,18 @@ $.extend( $.effects, { }, removeWrapper: function( element ) { - if ( element.parent().is( ".ui-effects-wrapper" ) ) - return element.parent().replaceWith( element ); + var active = document.activeElement; + + if ( element.parent().is( ".ui-effects-wrapper" ) ) { + element.parent().replaceWith( element ); + + // Fixes #7595 - Elements lose focus when wrapped. + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { + $( active ).focus(); + } + } + + return element; }, |