From 579ef2b3fbeb2b475ea9c6d426b1e84a964c25f1 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Thu, 7 Dec 2023 21:25:45 -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 Pull Request resolved: https://github.com/facebook/react-native/pull/41691 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 fbshipit-source-id: 372835a44edff361dbd84dd92ff9f2ec844b9f9c --- .../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 a838b5d28e1..12a8f509ffa 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: