Skip to content

Commit 7f587b3

Browse files
committed
Fix measurement bug
We were reading from the wrong fiber. Update the fixture to show that the document and the button remains interactive due to the inner boundary not resizing.
1 parent cb3f0c6 commit 7f587b3

2 files changed

Lines changed: 30 additions & 26 deletions

File tree

fixtures/view-transition/src/components/Page.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,34 @@ export default function Page() {
4646
}}>
4747
{show ? 'A' : 'B'}
4848
</button>
49-
{show ? (
50-
<div>
51-
{a}
52-
{b}
53-
</div>
54-
) : (
49+
<ViewTransition>
5550
<div>
56-
{b}
57-
{a}
51+
{show ? (
52+
<div>
53+
{a}
54+
{b}
55+
</div>
56+
) : (
57+
<div>
58+
{b}
59+
{a}
60+
</div>
61+
)}
62+
<ViewTransition>
63+
{show ? <div>hello{exclamation}</div> : <section>Loading</section>}
64+
</ViewTransition>
65+
{show ? null : (
66+
<ViewTransition>
67+
<div>world{exclamation}</div>
68+
</ViewTransition>
69+
)}
70+
<Activity mode={show ? 'visible' : 'hidden'}>
71+
<ViewTransition>
72+
<div>!!</div>
73+
</ViewTransition>
74+
</Activity>
5875
</div>
59-
)}
60-
<ViewTransition>
61-
{show ? <div>hello{exclamation}</div> : <section>Loading</section>}
6276
</ViewTransition>
63-
{show ? null : (
64-
<ViewTransition>
65-
<div>world{exclamation}</div>
66-
</ViewTransition>
67-
)}
68-
<Activity mode={show ? 'visible' : 'hidden'}>
69-
<ViewTransition>
70-
<div>!!</div>
71-
</ViewTransition>
72-
</Activity>
7377
</div>
7478
);
7579
}

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ function commitExitViewTransitions(
823823
}
824824
}
825825

826-
function commitBeforeUpdateViewTransition(fiber: Fiber): void {
826+
function commitBeforeUpdateViewTransition(current: Fiber): void {
827827
// The way we deal with multiple HostInstances as children of a View Transition in an
828828
// update can get tricky. The important bit is that if you swap out n HostInstances
829829
// from n HostInstances then they match up in order. Similarly, if you don't swap
@@ -840,12 +840,12 @@ function commitBeforeUpdateViewTransition(fiber: Fiber): void {
840840
// be unexpected but it is in line with the semantics that the ViewTransition is its
841841
// own layer that cross-fades its content when it updates. If you want to reorder then
842842
// each child needs its own ViewTransition.
843-
const name = getViewTransitionName(fiber.memoizedProps, fiber.stateNode);
843+
const name = getViewTransitionName(current.memoizedProps, current.stateNode);
844844
viewTransitionHostInstanceIdx = 0;
845845
applyViewTransitionToHostInstances(
846-
fiber.child,
846+
current.child,
847847
name,
848-
(fiber.memoizedState = []),
848+
(current.memoizedState = []),
849849
true,
850850
);
851851
}
@@ -1074,7 +1074,7 @@ function measureUpdateViewTransition(
10741074
// If nothing changed due to a mutation, or children changing size
10751075
// and the measurements end up unchanged, we should restore it to not animate.
10761076
viewTransitionHostInstanceIdx = 0;
1077-
const previousMeasurements = finishedWork.memoizedState;
1077+
const previousMeasurements = current.memoizedState;
10781078
const inViewport = measureViewTransitionHostInstances(
10791079
current,
10801080
finishedWork,

0 commit comments

Comments
 (0)