Skip to content

Commit 5ac2a64

Browse files
committed
YGLayout - restore support for moving views between superviews
1 parent 118a3d1 commit 5ac2a64

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/YogaKit/YGLayout.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,12 @@ static void YGAttachNodesFromViewHierachy(UIView* const view) {
489489
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
490490
YGRemoveAllChildren(node);
491491
for (int i = 0; i < subviewsToInclude.count; i++) {
492-
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
492+
YGNodeRef child = subviewsToInclude[i].yoga.node;
493+
YGNodeRef parent = YGNodeGetParent(child);
494+
if (parent != NULL) {
495+
YGNodeRemoveChild(parent, child);
496+
}
497+
YGNodeInsertChild(node, child, i);
493498
}
494499
}
495500

0 commit comments

Comments
 (0)