diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index 8abeaa76408..85870e59db5 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -1645,7 +1645,18 @@ static float distributeFreeSpaceSecondPass( const SizingMode childHeightSizingMode = !isMainAxisRow ? childMainSizingMode : childCrossSizingMode; - const bool isLayoutPass = performLayout && !requiresStretchLayout; + // A baseline-aligned item's baseline comes from the positions of its + // descendants, which only a layout pass sets, and the line's cross size + // comes from that baseline. Lay the item out even when the node is only + // measured, if the node is dirty: its own layout pass then follows in this + // layout and visits the item again. A clean node may never get one, so its + // items keep the layout, and the baselines, they have. + const bool needsLayoutForBaseline = node->isDirty() && + resolveChildAlignment(node, currentLineChild) == Align::Baseline && + !currentLineChild->hasBaselineFunc() && + currentLineChild->getLayoutChildCount() != 0; + const bool isLayoutPass = + (performLayout && !requiresStretchLayout) || needsLayoutForBaseline; // Recursively call the layout algorithm for this child with the updated // main size. calculateLayoutInternal(