From 3072d599c91290f8bafe7519306aaad512974df1 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 15 Aug 2018 14:21:55 -0700 Subject: [PATCH] Solve width bug when the size is less than min Summary: Removed the faulty calculation of `remainingFreeSpace` from the code. `remainingFreeSpace` already had the correct value that special condition was not required. Also added a test case for this issue Reviewed By: IanChilds Differential Revision: D9286928 fbshipit-source-id: 915269602cda2cc4515e6eab8184b2ea98d3e6d4 --- ReactCommon/yoga/yoga/Yoga.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 86d66956f17..36117082179 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -2396,20 +2396,13 @@ static void YGJustifyMainAxis( const bool& performLayout) { const YGStyle& style = node->getStyle(); - // If we are using "at most" rules in the main axis. Calculate the remaining - // space when constraint by the min size defined for the main axis. + // If we are using "at most" rules in the main axis, make sure that + // remainingFreeSpace is 0 when min main dimension is not given if (measureModeMainDim == YGMeasureModeAtMost && collectedFlexItemsValues.remainingFreeSpace > 0) { - if (style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined && - !YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize) - .isUndefined()) { - collectedFlexItemsValues.remainingFreeSpace = YGFloatMax( - 0, - YGUnwrapFloatOptional(YGResolveValue( - style.minDimensions[dim[mainAxis]], mainAxisownerSize)) - - (availableInnerMainDim - - collectedFlexItemsValues.remainingFreeSpace)); - } else { + if (style.minDimensions[dim[mainAxis]].unit == YGUnitUndefined || + YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize) + .isUndefined()) { collectedFlexItemsValues.remainingFreeSpace = 0; } }