Skip to content

Commit c7c7831

Browse files
jlmipfacebook-github-bot
authored andcommitted
Fixed issue with first line element gap handling.
Summary: If the first element of a line is not contributing (e.g. position absolute), an additional gap will be added to the line, because the first gap element of the line is never identified (wrong start index). Fix: raise the index of the first line element until we find an element that is contributing to the line. X-link: facebook/yoga#1408 Reviewed By: yungsters Differential Revision: D49722065 Pulled By: NickGerleman fbshipit-source-id: 1068cb0b11ae4b04ec8d063e70540cce06181d5a
1 parent d2742ce commit c7c7831

File tree

1 file changed

+7
-1
lines changed
  • packages/react-native/ReactCommon/yoga/yoga/algorithm

1 file changed

+7
-1
lines changed

packages/react-native/ReactCommon/yoga/yoga/algorithm/FlexLine.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ FlexLine calculateFlexLine(
2828
float totalFlexGrowFactors = 0.0f;
2929
float totalFlexShrinkScaledFactors = 0.0f;
3030
size_t endOfLineIndex = startOfLineIndex;
31+
size_t firstElementInLineIndex = startOfLineIndex;
3132

3233
float sizeConsumedIncludingMinConstraint = 0;
3334
const FlexDirection mainAxis = resolveDirection(
@@ -40,10 +41,15 @@ FlexLine calculateFlexLine(
4041
auto child = node->getChild(endOfLineIndex);
4142
if (child->getStyle().display() == Display::None ||
4243
child->getStyle().positionType() == PositionType::Absolute) {
44+
if (firstElementInLineIndex == endOfLineIndex) {
45+
// We haven't found the first contributing element in the line yet.
46+
firstElementInLineIndex++;
47+
}
4348
continue;
4449
}
4550

46-
const bool isFirstElementInLine = (endOfLineIndex - startOfLineIndex) == 0;
51+
const bool isFirstElementInLine =
52+
(endOfLineIndex - firstElementInLineIndex) == 0;
4753

4854
child->setLineIndex(lineCount);
4955
const float childMarginMainAxis =

0 commit comments

Comments
 (0)