Skip to content

Fix children being unparented after moving to another parent - #102

Merged
centau merged 2 commits into
centau:mainfrom
kaan650:fix-moved-children
Oct 22, 2026
Merged

centau merged 2 commits into
centau:mainfrom
kaan650:fix-moved-children

Conversation

@kaan650

@kaan650 kaan650 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

A children binding sets Parent = nil on the children it no longer has, and on all of its children when its scope is destroyed, without checking whether they are still parented to its instance. If a child was moved to another parent in the meantime, it gets removed from there.

local header = create "TextLabel" {}
local page = source "a"

local pages = switch(page) {
    a = function() return create "Frame" { function() return header end }, 0.5 end,
    b = function() return create "Frame" { function() return header end }, 0.5 end,
}

page "b" -- header moves to page b
-- 0.5 seconds later page a is destroyed and sets header.Parent to nil

The same happens when a child is moved from one children source to another and the new one updates first, or when the scope that parented a child is destroyed after the child was moved elsewhere. This only unparents children that are still parented to the binding's instance.

@centau
centau merged commit a75e3ee into centau:main Oct 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants