Skip to content

Commit 4adca58

Browse files
harsha-cppmeta-codesync[bot]
authored andcommitted
YGNodeFree: mark parent dirty when child is freed
Summary: fixes react/yoga#1659. **problem:** `YGNodeFree` called `owner->removeChild(node)` to detach the node from its parent, but never called `owner->markDirtyAndPropagate()`. the parent's layout stayed stale after the free, so a subsequent `YGNodeCalculateLayout` wouldn't recompute it. `YGNodeRemoveChild` has always called `markDirtyAndPropagate` — `YGNodeFree` was just missing the same call. `YGNodeFreeRecursive` was already correct for its recursive child removals (it calls `YGNodeRemoveChild` internally), but the terminal `YGNodeFree(root)` inherited the bug. **fix:** added `owner->markDirtyAndPropagate()` after `node->setOwner(nullptr)` in `YGNodeFree`. regression tests: `dirty_parent_when_child_freed` and `dirty_parent_when_subtree_freed_recursive` in `YGDirtyMarkingTest.cpp`. bypass-github-export-checks ## Changelog [General][Changed] - mark parent dirty when child is freed X-link: react/yoga#1969 Reviewed By: javache Differential Revision: D107895988 Pulled By: cipolleschi fbshipit-source-id: 5dce726e13147e8b7735bf72c441e80bb0c9b5a3
1 parent b41fffd commit 4adca58

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

  • packages/react-native/ReactCommon/yoga/yoga

packages/react-native/ReactCommon/yoga/yoga/YGNode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void YGNodeFree(const YGNodeRef nodeRef) {
4444
if (auto owner = node->getOwner()) {
4545
owner->removeChild(node);
4646
node->setOwner(nullptr);
47+
owner->markDirtyAndPropagate();
4748
}
4849

4950
const size_t childCount = node->getChildCount();

0 commit comments

Comments
 (0)