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
This commit is contained in:
Pritesh Nandgaonkar authored and Facebook Github Bot committed 2018-08-16 16:52:41 -07:00
1 parent 80bf73116d
commit 3072d599c9
1 file changed
+5 -12
+5 -12
View File
@@ -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;
}
}