From aa8eb806ca966e3ee3896c9cc5ddc4a33c7fd283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Wed, 20 Sep 2017 13:17:34 -0700 Subject: [PATCH] Fix shrinking in non strech alignments Summary: This fixes shrinking of elements which are in a non stretch alignment Fixes #633 Closes https://github.com/facebook/yoga/pull/634 Differential Revision: D5874862 Pulled By: emilsjolander fbshipit-source-id: 1426aa6b60f6ba42c2be702e6f24cea935ab7acb --- ReactCommon/yoga/yoga/Yoga.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactCommon/yoga/yoga/Yoga.c b/ReactCommon/yoga/yoga/Yoga.c index 84aa5a757..26489faac 100644 --- a/ReactCommon/yoga/yoga/Yoga.c +++ b/ReactCommon/yoga/yoga/Yoga.c @@ -2308,6 +2308,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If the main dimension size isn't known, it is computed based on // the line length, so there's no more space left to distribute. + bool sizeBasedOnContent = false; // If we don't measure with exact main dimension we want to ensure we don't violate min and max if (measureModeMainDim != YGMeasureModeExactly) { if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) { @@ -2322,11 +2323,12 @@ static void YGNodelayoutImpl(const YGNodeRef node, // space we've used is all space we need. Root node also should be shrunk to minimum availableInnerMainDim = sizeConsumedOnCurrentLine; } + sizeBasedOnContent = true; } } float remainingFreeSpace = 0; - if (!YGFloatIsUndefined(availableInnerMainDim)) { + if (!sizeBasedOnContent && !YGFloatIsUndefined(availableInnerMainDim)) { remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; } else if (sizeConsumedOnCurrentLine < 0) { // availableInnerMainDim is indefinite which means the node is being sized based on its