diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 88c77ab850..a66adec123 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -2540,6 +2540,11 @@ 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 + if (isLastChild) { + betweenMainDim -= gap; + } if (childStyle.display() == YGDisplayNone) { continue; }