Permalink
Browse files

Measure nodes which have margin: auto and align-item: stretch

Summary:
If you have a measurable node and set ```marign-left: auto``` + ```align-item:stretch``` on it, it won't get measured and they get a width/height of ```-(nan)```. This change fixes that behaviour. Fixes #644.
Closes facebook/yoga#645

Differential Revision: D6413512

Pulled By: emilsjolander

fbshipit-source-id: 755febeb33bb0d4520ca6b3c28d56ac333e4a14d
  • Loading branch information...
woehrl01 authored and facebook-github-bot committed Nov 27, 2017
1 parent 1050e0b commit 5f99b1a55f4002c105a7005cabf720aad422b628
Showing with 6 additions and 2 deletions.
  1. +6 −2 ReactCommon/yoga/yoga/Yoga.cpp
@@ -2327,7 +2327,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
availableInnerCrossDim) &&
measureModeCrossDim == YGMeasureModeExactly &&
!(isNodeFlexWrap && flexBasisOverflows) &&
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) {
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch &&
YGMarginLeadingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto &&
YGMarginTrailingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto) {
childCrossSize = availableInnerCrossDim;
childCrossMeasureMode = YGMeasureModeExactly;
} else if (!YGNodeIsStyleDimDefined(currentRelativeChild,
@@ -2363,7 +2365,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
const bool requiresStretchLayout =
!YGNodeIsStyleDimDefined(currentRelativeChild, crossAxis, availableInnerCrossDim) &&
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch;
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch &&
YGMarginLeadingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto &&
YGMarginTrailingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto;
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;

0 comments on commit 5f99b1a

Please sign in to comment.