Skip to content

Commit f90c9b5

Browse files
Adam Comellafacebook-github-bot
authored andcommitted
When paddingStart is 0, it should override paddingHorizontal (#816)
Summary: Fixes #815 Imagine a node with this style: `{ paddingHorizontal: 10, paddingStart: 0 }`. After running layout on this node, we expect its computed `paddingStart` to be `0`. However, it is actually `10`. Consider the expression `paddingEdgeStart.getValue() > 0.0f` in [`getLeadingPadding`](https://github.com/facebook/yoga/blob/328ec7dc4d104b42b836d5ccebff04033d045133/yoga/YGNode.cpp#L461). Why is `0` handled like a negative number rather than a positive number? I suspect this should be `>=` so `0` is handled like the positive numbers (this is how `getTrailingPadding` works). It looks like facebook/yoga@3a82d2b?diff=unified&w=1#diff-07b4949bf42749fde386e769ff08a124 changed the operator from `>=` to `>` in `getLeadingPadding`. I suspect it was a mistake. `getTrailingPadding` still uses `>=`. I manually verified this using the code in #815 and added some unit tests to catch this bug and other similar issues. Adam Comella Microsoft Corp. Pull Request resolved: facebook/yoga#816 Reviewed By: priteshrnandgaonkar Differential Revision: D10282617 Pulled By: shergin fbshipit-source-id: 2ab2874ae39d9454308a020a960ace85573fe777
1 parent 10fc548 commit f90c9b5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ReactCommon/yoga/yoga/YGNode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) Facebook, Inc. and its affiliates.
2+
* Copyright (c) 2018-present, Facebook, Inc.
33
*
44
* This source code is licensed under the MIT license found in the LICENSE
55
* file in the root directory of this source tree.
@@ -458,7 +458,7 @@ YGFloatOptional YGNode::getLeadingPadding(
458458
YGResolveValue(style_.padding[YGEdgeStart], widthSize);
459459
if (YGFlexDirectionIsRow(axis) &&
460460
style_.padding[YGEdgeStart].unit != YGUnitUndefined &&
461-
!paddingEdgeStart.isUndefined() && paddingEdgeStart.getValue() > 0.0f) {
461+
!paddingEdgeStart.isUndefined() && paddingEdgeStart.getValue() >= 0.0f) {
462462
return paddingEdgeStart;
463463
}
464464

0 commit comments

Comments
 (0)