File tree Expand file tree Collapse file tree 2 files changed +32
-5
lines changed Expand file tree Collapse file tree 2 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -167,13 +167,13 @@ export default function useStatus(
167167 useIsomorphicLayoutEffect ( ( ) => {
168168 setAsyncVisible ( visible ) ;
169169
170+ const isMounted = mountedRef . current ;
171+ mountedRef . current = true ;
172+
170173 if ( ! supportMotion ) {
171174 return ;
172175 }
173176
174- const isMounted = mountedRef . current ;
175- mountedRef . current = true ;
176-
177177 let nextStatus : MotionStatus ;
178178
179179 // Appear
Original file line number Diff line number Diff line change @@ -265,7 +265,10 @@ describe('CSSMotion', () => {
265265 } ) ;
266266 }
267267
268- test ( 'without ref' , React . forwardRef ( props => < div { ...props } /> ) ) ;
268+ test (
269+ 'without ref' ,
270+ React . forwardRef ( ( props ) => < div { ...props } /> ) ,
271+ ) ;
269272
270273 test (
271274 'FC with ref' ,
@@ -364,6 +367,30 @@ describe('CSSMotion', () => {
364367 } ) ;
365368 } ) ;
366369
370+ it ( 'not block motion when motion set delay' , ( ) => {
371+ const wrapper = mount (
372+ < CSSMotion visible >
373+ { ( { style, className } ) => (
374+ < div style = { style } className = { classNames ( 'motion-box' , className ) } />
375+ ) }
376+ </ CSSMotion > ,
377+ ) ;
378+
379+ wrapper . setProps ( {
380+ motionName : 'animation' ,
381+ motionLeave : true ,
382+ visible : false ,
383+ } ) ;
384+
385+ act ( ( ) => {
386+ jest . runAllTimers ( ) ;
387+ wrapper . update ( ) ;
388+ } ) ;
389+
390+ const activeBoxNode = wrapper . find ( '.motion-box' ) ;
391+ expect ( activeBoxNode . hasClass ( `animation-leave-active` ) ) . toBeTruthy ( ) ;
392+ } ) ;
393+
367394 describe ( 'immediately' , ( ) => {
368395 it ( 'motionLeaveImmediately' , async ( ) => {
369396 const wrapper = mount (
@@ -525,7 +552,7 @@ describe('CSSMotion', () => {
525552 let lockResolve : Function ;
526553 const onAppearPrepare = jest . fn (
527554 ( ) =>
528- new Promise ( resolve => {
555+ new Promise ( ( resolve ) => {
529556 lockResolve = resolve ;
530557 } ) ,
531558 ) ;
You can’t perform that action at this time.
0 commit comments