diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index 398e5e9af6f..3728235181c 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -2018,7 +2018,8 @@ static void justifyMainAxis( flexLine.layout.mainDim += child->dimensionWithMargin(mainAxis, availableInnerWidth); - if (isNodeBaselineLayout) { + if (isNodeBaselineLayout && + resolveChildAlignment(node, child) == Align::Baseline) { // If the child is baseline aligned then the cross dimension is // calculated by adding maxAscent and maxDescent from the baseline. const float ascent = calculateBaseline(child) + @@ -2037,7 +2038,7 @@ static void justifyMainAxis( } else { // The cross dimension is the max of the elements dimension since // there can only be one element in that cross dimension in the case - // when the items are not baseline aligned + // when the item is not baseline aligned flexLine.layout.crossDim = yoga::maxOrDefined( flexLine.layout.crossDim, child->dimensionWithMargin(crossAxis, availableInnerWidth)); @@ -2047,8 +2048,11 @@ static void justifyMainAxis( flexLine.layout.mainDim += trailingPaddingAndBorderMain; if (isNodeBaselineLayout) { - flexLine.layout.crossDim = - maxAscentForCurrentLine + maxDescentForCurrentLine; + // The line fits both its baseline-aligned items, placed on their shared + // baseline, and its largest other item (css-flexbox-1 ยง9.4, step 8). + flexLine.layout.crossDim = yoga::maxOrDefined( + flexLine.layout.crossDim, + maxAscentForCurrentLine + maxDescentForCurrentLine); } }