Fix position of TextInlineViews when nesting multiple Text components

Summary:
This diff fixes the position of TextInlineViews when nesting multiple Text.
The root is that we were not taking into consideration LayoutOffset of nested TextViews during the calculation of the nested views.

changelog: [Internal] Internal fix in Fabric

Reviewed By: JoshuaGross

Differential Revision: D21586893

fbshipit-source-id: 55e6ad0cf95222588ffe9185f5e22baea1059448
This commit is contained in:
David Vacca 2020-05-14 21:40:11 -07:00 коммит произвёл Facebook GitHub Bot
Родитель cf171e4e04
Коммит 84bca09f87
3 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -25,6 +25,21 @@ function Basic(): React.Node {
);
}
function NestedTexts(): React.Node {
return (
<View>
<Text>This is the first row</Text>
<Text>
<Text>
<Text>This is a nested text </Text>
<View style={{height: 20, width: 20, backgroundColor: 'red'}} />
<Text> with a Red View</Text>
</Text>
</Text>
</View>
);
}
function ClippedByText(): React.Node {
return (
<View>
@ -200,6 +215,7 @@ class ChangeInnerViewSize extends React.Component<*, ChangeSizeState> {
module.exports = {
Basic,
NestedTexts,
ClippedByText,
ChangeImageSize,
ChangeViewSize,

Просмотреть файл

@ -664,6 +664,9 @@ class TextExample extends React.Component<{...}> {
<RNTesterBlock title="Inline views">
<TextInlineView.Basic />
</RNTesterBlock>
<RNTesterBlock title="Inline views with multiple nested texts">
<TextInlineView.NestedTexts />
</RNTesterBlock>
<RNTesterBlock title="Inline image/view clipped by <Text>">
<TextInlineView.ClippedByText />
</RNTesterBlock>

Просмотреть файл

@ -189,7 +189,9 @@ static void sliceChildShadowNodeViewPairsRecursively(
for (auto const &sharedChildShadowNode : shadowNode.getChildren()) {
auto &childShadowNode = *sharedChildShadowNode;
auto shadowView = ShadowView(childShadowNode);
auto origin = layoutOffset;
if (shadowView.layoutMetrics != EmptyLayoutMetrics) {
origin += shadowView.layoutMetrics.frame.origin;
shadowView.layoutMetrics.frame.origin += layoutOffset;
}
@ -203,7 +205,7 @@ static void sliceChildShadowNodeViewPairsRecursively(
}
sliceChildShadowNodeViewPairsRecursively(
pairList, shadowView.layoutMetrics.frame.origin, childShadowNode);
pairList, origin, childShadowNode);
}
}
}