@@ -11,9 +11,19 @@ import type {FiberRoot} from './ReactInternalTypes';
1111import type { GestureOptions } from 'shared/ReactTypes' ;
1212import type { GestureTimeline , RunningViewTransition } from './ReactFiberConfig' ;
1313import type { TransitionTypes } from 'react/src/ReactTransitionType' ;
14+ import type { Lane } from './ReactFiberLane' ;
1415
15- import { GestureLane , markRootFinished , NoLane , NoLanes } from './ReactFiberLane' ;
16- import { ensureRootIsScheduled } from './ReactFiberRootScheduler' ;
16+ import {
17+ GestureLane ,
18+ markRootEntangled ,
19+ markRootFinished ,
20+ NoLane ,
21+ NoLanes ,
22+ } from './ReactFiberLane' ;
23+ import {
24+ ensureRootIsScheduled ,
25+ requestTransitionLane ,
26+ } from './ReactFiberRootScheduler' ;
1727import { getCurrentGestureOffset , stopViewTransition } from './ReactFiberConfig' ;
1828import { pingGestureRoot , restartGestureRoot } from './ReactFiberWorkLoop' ;
1929
@@ -26,6 +36,7 @@ export type ScheduledGesture = {
2636 types : null | TransitionTypes , // Any addTransitionType call made during startGestureTransition.
2737 running : null | RunningViewTransition , // Used to cancel the running transition after we're done.
2838 committing : boolean , // If the gesture was released in a committed state and should actually commit.
39+ revertLane : Lane , // The Lane that we'll use to schedule the revert.
2940 prev : null | ScheduledGesture , // The previous scheduled gesture in the queue for this root.
3041 next : null | ScheduledGesture , // The next scheduled gesture in the queue for this root.
3142} ;
@@ -54,6 +65,7 @@ export function scheduleGesture(
5465 types : null ,
5566 running : null ,
5667 committing : false ,
68+ revertLane : NoLane , // Starts uninitialized.
5769 prev : prev ,
5870 next : null ,
5971 } ;
@@ -119,6 +131,13 @@ export function cancelScheduledGesture(
119131 root : FiberRoot ,
120132 gesture : ScheduledGesture ,
121133) : void {
134+ // Entangle any Transitions started in this event with the revertLane of the gesture
135+ // so that we commit them all together.
136+ if ( gesture . revertLane !== NoLane ) {
137+ const entangledLanes = gesture . revertLane | requestTransitionLane ( null ) ;
138+ markRootEntangled ( root , entangledLanes ) ;
139+ }
140+
122141 gesture . count -- ;
123142 if ( gesture . count === 0 ) {
124143 // If the end state is closer to the end than the beginning then we commit into the
0 commit comments