fix: remove gap if its last element in line (fix flex gap extra spacing when children determine parents main axis size) (#1188)
Summary: Fixes - https://github.com/facebook/react-native/issues/35553 ## Approach We're using `betweenMainDim` to add [gap between](bbeede82d3/yoga/Yoga.cpp (L2495)
) items in main axis. This is resulting in increased [main axis](bbeede82d3/yoga/Yoga.cpp (L2598)
) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached. ## Aside Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏 Pull Request resolved: https://github.com/facebook/yoga/pull/1188 Test Plan: Added fixtures which previously failed but now pass. Reviewed By: necolas Differential Revision: D42078162 Pulled By: NickGerleman fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
35f3335efc
commit
ba27f9d1ec
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user