Move a child out of its old container when it is added to another - #175
Merged
Merged
Conversation
…r [patch] AddChild set Parent without detaching the child from its previous container, so the child sat in both, and RemoveChild on the old one then nulled Parent while the child was still in the new one. AddChild now removes the child from its previous parent first, and RemoveChild/ClearChildren only clear Parent when it still points at this container. Fixes #144 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCL6GX9wshgqiBeq6z98ZH
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #144
What changed
UIContainerBase.AddChildsetchild.Parent = thiswithout detaching the child from its current container. The child ended up in both containers, rendered twice, and raisedInvalidatedon both.RemoveChildon the old container then setParentto null even though the child was still in the new one.AddChildnow removes the child from its previous parent before adopting it.RemoveChildandClearChildrenonly clearParentwhen it still points at this container.Tests
New
UIContainerBaseTestschecks the issue's acceptance criteria:a.AddChild(c); b.AddChild(c);,cis only inb.Childrenandc.Parent == b.a.RemoveChild(c)returns false and leavesc.Parentasb.All three failed before the fix. The full suite passes with it (212/212).
🤖 Generated with Claude Code
https://claude.ai/code/session_01VCL6GX9wshgqiBeq6z98ZH
Generated by Claude Code