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
2018-08-15 14:21:55 -07:00
committed by Facebook Github Bot
parent 8368338c93
commit b872751d68
4 changed files with 190 additions and 23 deletions

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;
}
}