From dd52225dca73a1b27a4342232eb9b3f6c279dcb8 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Wed, 6 Dec 2023 17:35:34 -0800 Subject: [PATCH] Fix issue where we were not applying flex end correctly when justifying (#41691) Summary: X-link: https://github.com/facebook/yoga/pull/1487 The code here was just wrong. I changed it to be the same logic as the Justify:FlexStart case, but with the flex end sides. Then I get the position for the opposite edge since we need to write to flex start side. Reviewed By: NickGerleman Differential Revision: D51383792 --- .../ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp index a838b5d28e1562..12a8f509ffaae0 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp @@ -31,8 +31,14 @@ static void justifyAbsoluteChild( break; case Justify::FlexEnd: child->setLayoutPosition( - (parent->getLayout().measuredDimension(dimension(mainAxis)) - - child->getLayout().measuredDimension(dimension(mainAxis))), + getPositionOfOppositeEdge( + parent->getLayout().border(flexEndEdge(mainAxis)) + + parent->getLayout().padding(flexEndEdge(mainAxis)) + + child->getFlexEndMargin( + mainAxis, direction, containingBlockWidth), + mainAxis, + parent, + child), flexStartEdge(mainAxis)); break; case Justify::Center: