From 9a0047f3682f053396ff8fc7ad39cb4e72117955 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 18 Mar 2019 19:16:40 -0700 Subject: [PATCH] Fabric: Explicit dirtying Yoga nodes for Text component (and co.) Summary: With recent changes, simple cloning a component does not mean that underlying Yoga node will be dirtied. Autodirtying is only performed if the child nodes were dirtied and/or if the YGStyles were changed. That's not the case for Text component which does not have direct layotable children, so we have to call `dirtyLayout` explicitly. Reviewed By: JoshuaGross Differential Revision: D14508277 fbshipit-source-id: 2c52d7d40da963a976c7d28a13781cc1755ef591 --- .../components/text/paragraph/ParagraphComponentDescriptor.h | 2 ++ .../fabric/components/view/yoga/YogaLayoutableShadowNode.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ReactCommon/fabric/components/text/paragraph/ParagraphComponentDescriptor.h b/ReactCommon/fabric/components/text/paragraph/ParagraphComponentDescriptor.h index 499490db685..7e7974b42ef 100644 --- a/ReactCommon/fabric/components/text/paragraph/ParagraphComponentDescriptor.h +++ b/ReactCommon/fabric/components/text/paragraph/ParagraphComponentDescriptor.h @@ -71,6 +71,8 @@ class ParagraphComponentDescriptor final paragraphShadowNode->setMeasureCache( measureCache_ ? measureCache_.get() : nullptr); + paragraphShadowNode->dirtyLayout(); + // All `ParagraphShadowNode`s must have leaf Yoga nodes with properly // setup measure function. paragraphShadowNode->enableMeasurement(); diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index 26b870d0d0e..7b198efc687 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -141,6 +141,7 @@ void YogaLayoutableShadowNode::setSize(Size size) const { style.dimensions[YGDimensionWidth] = yogaStyleValueFromFloat(size.width); style.dimensions[YGDimensionHeight] = yogaStyleValueFromFloat(size.height); yogaNode_.setStyle(style); + yogaNode_.setDirty(true); } void YogaLayoutableShadowNode::setPositionType( @@ -150,6 +151,7 @@ void YogaLayoutableShadowNode::setPositionType( auto style = yogaNode_.getStyle(); style.positionType = positionType; yogaNode_.setStyle(style); + yogaNode_.setDirty(true); } void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {