Skip to content

Commit

Permalink
chore: update state update affecting onlayout phase trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
azimgd committed Dec 29, 2024
1 parent c33e7bb commit c7bceb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ class SLContainerComponentDescriptor : public ConcreteComponentDescriptor<SLCont
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;

void adopt(ShadowNode& shadowNode) const override {
/*
* Temporary fix to force the triggering of the shadow node's layout phase
* as for some reason the shadow node doesn't re-layout upon a state update
*/
auto& containerShadowNodeLayoutable = static_cast<YogaLayoutableShadowNode&>(shadowNode);
containerShadowNodeLayoutable.setSize({500, 500});

ConcreteComponentDescriptor::adopt(shadowNode);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ void SLContainerShadowNode::layout(LayoutContext layoutContext) {
auto elementShadowNodeLayoutable = std::static_pointer_cast<YogaLayoutableShadowNode>(elementShadowNodeComponentRegistry[elementDataUniqueKey]);

if (elementShadowNodeLayoutable->getLayoutMetrics().frame.size.height == 0) {
elementShadowNodeLayoutable->layoutTree(layoutContext, {});
LayoutConstraints layoutConstraints = {};
layoutConstraints.minimumSize.width = getLayoutMetrics().frame.size.width;
layoutConstraints.maximumSize.width = getLayoutMetrics().frame.size.width;
elementShadowNodeLayoutable->layoutTree(layoutContext, layoutConstraints);
}

nextStateData.childrenMeasurementsTree[elementDataIndex] = elementShadowNodeLayoutable->getLayoutMetrics().frame.size.height;
Expand Down Expand Up @@ -167,6 +170,7 @@ void SLContainerShadowNode::layout(LayoutContext layoutContext) {
}

this->children_ = containerShadowNodeChildren;
yogaNode_.setDirty(true);

nextStateData.firstChildUniqueId = props.getElementValueByPath(props.data.front(), "id");
nextStateData.lastChildUniqueId = props.getElementValueByPath(props.data.back(), "id");
Expand Down

0 comments on commit c7bceb5

Please sign in to comment.