Skip to content

Commit e7827be

Browse files
woehrl01bowerman0
authored andcommitted
Fix shrinking in non strech alignments while retaining legacy behaviour
Summary: This fixes shrinking of elements which are in a non stretch alignment, but keeps the legacy stretch behaviour in place. Additionally this adds a testcase for ```useLegacyStretchBehaviour``` Fixes facebook#633 Closes facebook/yoga#635 Differential Revision: D6408037 Pulled By: emilsjolander fbshipit-source-id: 377ab0308dd3a75a148a0af31ab5eb3ffb5b5d83
1 parent 4ede379 commit e7827be

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ReactCommon/yoga/yoga/Yoga.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
21232123
// If the main dimension size isn't known, it is computed based on
21242124
// the line length, so there's no more space left to distribute.
21252125

2126+
bool sizeBasedOnContent = false;
21262127
// If we don't measure with exact main dimension we want to ensure we don't violate min and max
21272128
if (measureModeMainDim != YGMeasureModeExactly) {
21282129
if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) {
@@ -2137,11 +2138,12 @@ static void YGNodelayoutImpl(const YGNodeRef node,
21372138
// space we've used is all space we need. Root node also should be shrunk to minimum
21382139
availableInnerMainDim = sizeConsumedOnCurrentLine;
21392140
}
2141+
sizeBasedOnContent = !node->config->useLegacyStretchBehaviour;
21402142
}
21412143
}
21422144

21432145
float remainingFreeSpace = 0;
2144-
if (!YGFloatIsUndefined(availableInnerMainDim)) {
2146+
if (!sizeBasedOnContent && !YGFloatIsUndefined(availableInnerMainDim)) {
21452147
remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine;
21462148
} else if (sizeConsumedOnCurrentLine < 0) {
21472149
// availableInnerMainDim is indefinite which means the node is being sized based on its

0 commit comments

Comments
 (0)