From ecd7790dd8192b4c2944f85e28df2fc589b908c0 Mon Sep 17 00:00:00 2001 From: Sidharth Guglani Date: Wed, 1 Apr 2020 14:37:45 -0700 Subject: [PATCH] Fix Yoga flexshrink with min-width sizing issue Summary: While resolving the flexible items we calculate totalFlexShrinkScaledFactors which uses the flexBasis or initial width of node (Not min-width). At a later stage during distribution of space we are subtracting value from this which also takes care of min-width. For example If node has flexShrink 1 and width 100 and min-width 301 then totalFlexShrinkScaledFactors will become -1*100 = -100 but later we are subtracting -1 * 301 (min-width) = -301 which is ambiguous and causing layout inconsistencies with how web behaves. Fixed this by only using the flexBasis or width for these calculations. Changelog: [Internal][Yoga] Fix layout issue when flexShrink and min-width are used together Reviewed By: pasqualeanatriello Differential Revision: D20219419 fbshipit-source-id: 948fbc06ca541d4ad307c88c8a2df65d157778b1 --- yoga/Yoga.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index e30a36b7..d916a45f 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -2338,7 +2338,8 @@ static void YGDistributeFreeSpaceFirstPass( // first and second passes. deltaFreeSpace += boundMainSize - childFlexBasis; collectedFlexItemsValues.totalFlexShrinkScaledFactors -= - flexShrinkScaledFactor; + (-currentRelativeChild->resolveFlexShrink() * + currentRelativeChild->getLayout().computedFlexBasis.unwrap()); } } } else if (