diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 88c77ab8..8b7b1c2b 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -2540,6 +2540,9 @@ static void YGJustifyMainAxis( const YGNodeRef child = node->getChild(i); const YGStyle& childStyle = child->getStyle(); const YGLayout childLayout = child->getLayout(); + const bool isLastChild = i == collectedFlexItemsValues.endOfLineIndex - 1; + // remove the gap if it is the last element of the line + betweenMainDim -= isLastChild ? gap : 0; if (childStyle.display() == YGDisplayNone) { continue; }