diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index 4822e13955e..3d7e570e520 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -1725,7 +1725,8 @@ static void justifyMainAxis( const float availableInnerMainDim, const float availableInnerCrossDim, const float availableInnerWidth, - const bool performLayout) { + const bool performLayout, + const bool isNodeBaselineLayout) { const auto& style = node->style(); const float leadingPaddingAndBorderMain = @@ -1821,7 +1822,6 @@ static void justifyMainAxis( float maxAscentForCurrentLine = 0; float maxDescentForCurrentLine = 0; - bool isNodeBaselineLayout = isBaselineLayout(node); for (auto child : flexLine.itemsInFlow) { const LayoutResults& childLayout = child->getLayout(); if (child->style().flexStartMarginIsAuto(mainAxis, direction) && @@ -2223,6 +2223,7 @@ static void calculateLayoutImpl( // Max main dimension of all the lines. float maxLineMainDim = 0; + const bool isNodeBaselineLayout = isBaselineLayout(node); for (; startOfLineIterator != node->getLayoutChildren().end(); lineCount++) { auto flexLine = calculateFlexLine( node, @@ -2361,7 +2362,8 @@ static void calculateLayoutImpl( availableInnerMainDim, availableInnerCrossDim, availableInnerWidth, - performLayout); + performLayout, + isNodeBaselineLayout); float containerCrossAxis = availableInnerCrossDim; if (sizingModeCrossDim == SizingMode::MaxContent || @@ -2523,7 +2525,7 @@ static void calculateLayoutImpl( // STEP 8: MULTI-LINE CONTENT ALIGNMENT // currentLead stores the size of the cross dim - if (performLayout && (isNodeFlexWrap || isBaselineLayout(node))) { + if (performLayout && (isNodeFlexWrap || isNodeBaselineLayout)) { float leadPerLine = 0; float currentLead = leadingPaddingAndBorderCross; float extraSpacePerLine = 0;