@@ -210,6 +210,7 @@ import {
210
210
TransitionRoot ,
211
211
TransitionTracingMarker ,
212
212
} from './ReactFiberTracingMarkerComponent' ;
213
+ import { getViewTransitionClassName } from './ReactFiberViewTransitionComponent' ;
213
214
import {
214
215
commitHookLayoutEffects ,
215
216
commitHookLayoutUnmountEffects ,
@@ -303,6 +304,7 @@ export let shouldFireAfterActiveInstanceBlur: boolean = false;
303
304
// Used during the commit phase to track whether a parent ViewTransition component
304
305
// might have been affected by any mutations / relayouts below.
305
306
let viewTransitionContextChanged : boolean = false ;
307
+ let inUpdateViewTransition : boolean = false ;
306
308
let rootViewTransitionAffected : boolean = false ;
307
309
308
310
function isHydratingParent ( current : Fiber , finishedWork : Fiber ) : boolean {
@@ -1937,6 +1939,7 @@ export function commitMutationEffects(
1937
1939
inProgressRoot = root ;
1938
1940
1939
1941
rootViewTransitionAffected = false ;
1942
+ inUpdateViewTransition = false ;
1940
1943
1941
1944
resetComponentEffectTimers ( ) ;
1942
1945
@@ -2299,7 +2302,7 @@ function commitMutationEffectsOnFiber(
2299
2302
recursivelyTraverseMutationEffects ( root , finishedWork , lanes ) ;
2300
2303
commitReconciliationEffects ( finishedWork , lanes ) ;
2301
2304
}
2302
- if ( viewTransitionMutationContext ) {
2305
+ if ( viewTransitionMutationContext && inUpdateViewTransition ) {
2303
2306
// A Portal doesn't necessarily exist within the context of this subtree.
2304
2307
// Ideally we would track which React ViewTransition component nests the container
2305
2308
// but that's costly. Instead, we treat each Portal as if it's a new React root.
@@ -2534,6 +2537,10 @@ function commitMutationEffectsOnFiber(
2534
2537
}
2535
2538
}
2536
2539
const prevMutationContext = pushMutationContext ( ) ;
2540
+ const prevUpdate = inUpdateViewTransition ;
2541
+ const props = finishedWork . memoizedProps ;
2542
+ inUpdateViewTransition =
2543
+ getViewTransitionClassName ( props . default , props . update ) !== 'none' ;
2537
2544
recursivelyTraverseMutationEffects ( root , finishedWork , lanes ) ;
2538
2545
commitReconciliationEffects ( finishedWork , lanes ) ;
2539
2546
const isViewTransitionEligible =
@@ -2551,6 +2558,7 @@ function commitMutationEffectsOnFiber(
2551
2558
finishedWork . flags |= Update ;
2552
2559
}
2553
2560
}
2561
+ inUpdateViewTransition = prevUpdate ;
2554
2562
popMutationContext ( prevMutationContext ) ;
2555
2563
break ;
2556
2564
}
@@ -2763,6 +2771,8 @@ function commitAfterMutationEffectsOnFiber(
2763
2771
// Ideally we would track which React ViewTransition component nests the container
2764
2772
// but that's costly. Instead, we treat each Portal as if it's a new React root.
2765
2773
// Therefore any leaked resize of a child could affect the root so the root should animate.
2774
+ // We only do this if the Portal is inside a ViewTransition and it is not disabled
2775
+ // with update="none". Otherwise the Portal is considered not animating.
2766
2776
rootViewTransitionAffected = true ;
2767
2777
}
2768
2778
viewTransitionContextChanged = prevContextChanged ;
0 commit comments