From 8866aa7e79b4ba9d2bf3484c55c6b2b47a761e4b Mon Sep 17 00:00:00 2001 From: GitHub Workflows Support Date: Mon, 30 Nov 2026 09:02:47 -0800 Subject: [PATCH] Skip `display: none` children when finding a flex container's baseline (#2107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: A `display: none` child is not a flex item, so it cannot supply its container's baseline (css-flexbox-1 ยง8.5) or make its row a baseline layout. `calculateBaseline` chose a hidden first child, whose zeroed-out layout has a NaN measured height, and `isBaselineLayout` counted a hidden `align-self: baseline` child. `calculateBaseline` also read the line index of children that are not flex items before skipping them. Only flex items are assigned to lines, so a stale index from an earlier layout could end the search early. Reviewed By: javache Differential Revision: D135033729 --- .../ReactCommon/yoga/yoga/algorithm/Baseline.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/Baseline.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/Baseline.cpp index b3002012bc06..0ebf66524e00 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/Baseline.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/Baseline.cpp @@ -33,12 +33,15 @@ float calculateBaseline(const yoga::Node* node) { yoga::Node* baselineChild = nullptr; for (auto child : node->getLayoutChildren()) { + // Children that are not flex items take no part in baseline alignment, and + // their line index is stale: only flex items are assigned to lines. + if (child->style().positionType() == PositionType::Absolute || + child->style().display() == Display::None) { + continue; + } if (child->getLineIndex() > 0) { break; } - if (child->style().positionType() == PositionType::Absolute) { - continue; - } if (resolveChildAlignment(node, child) == Align::Baseline || child->isReferenceBaseline()) { baselineChild = child; @@ -67,6 +70,7 @@ bool isBaselineLayout(const yoga::Node* node) { } for (auto child : node->getLayoutChildren()) { if (child->style().positionType() != PositionType::Absolute && + child->style().display() != Display::None && child->style().alignSelf() == Align::Baseline) { return true; }