Skip to content

Commit 6806593

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
fix a regression introduced by fixYogaFlexBasisFitContentInMainAxis feature flag
Summary: X-link: facebook/react-native#56839 Limit the FixFlexBasisFitContent height optimization to non-measure container children inside scroll subtrees. This keeps Marketplace Home wrappers outside the ScrollView viewport-bounded while preserving the scroll remeasurement optimization. This regression was discovered during a recent QE where I tried to run enable this optimisation. Reviewed By: christophpurrer Differential Revision: D105167981
1 parent aa9c6fd commit 6806593

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

yoga/algorithm/CalculateLayout.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ static void computeFlexBasisForChild(
177177

178178
// For height in the main axis (column direction): when the
179179
// FixFlexBasisFitContent feature is enabled, skip FitContent for
180-
// non-measure container children. This makes the flex basis independent
181-
// of the parent's content-determined height, preventing unnecessary
182-
// re-measurement cascades when a sibling changes size in a ScrollView.
180+
// non-measure container children inside scroll subtrees. This makes the
181+
// flex basis independent of content-determined heights, preventing
182+
// unnecessary re-measurement cascades when a sibling changes size in a
183+
// ScrollView, while preserving viewport bounds for wrappers outside the
184+
// scroll subtree.
183185
//
184186
// We only optimize the height (column) axis because text wrapping depends
185187
// on width constraints propagating through container nodes. Removing
@@ -188,8 +190,16 @@ static void computeFlexBasisForChild(
188190
bool applyHeightFitContent =
189191
isMainAxisRow || node->style().overflow() != Overflow::Scroll;
190192
if (fixFlexBasisFitContent) {
193+
bool nodeHasScrollAncestor = false;
194+
for (auto owner = node->getOwner(); owner != nullptr;
195+
owner = owner->getOwner()) {
196+
if (owner->style().overflow() == Overflow::Scroll) {
197+
nodeHasScrollAncestor = true;
198+
break;
199+
}
200+
}
191201
applyHeightFitContent = isMainAxisRow ||
192-
(child->hasMeasureFunc() &&
202+
((child->hasMeasureFunc() || !nodeHasScrollAncestor) &&
193203
node->style().overflow() != Overflow::Scroll);
194204
}
195205
if (applyHeightFitContent && yoga::isUndefined(childHeight) &&

0 commit comments

Comments
 (0)