From 8a579f0b98963bcbbcb28e94d57763754c93e8fb Mon Sep 17 00:00:00 2001 From: Zyie <24736175+Zyie@users.noreply.github.com> Date: Wed, 24 Sep 2025 09:53:53 +0100 Subject: [PATCH] fix: Adds missing children after becoming visible Ensures that children added to the display list after becoming visible are properly integrated into the layout. This prevents issues where newly visible elements were not being added to the layout, leading to incorrect positioning. --- src/core/Layout.ts | 5 ++++- src/core/utils/sort-children.ts | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/Layout.ts b/src/core/Layout.ts index b6c8b05..f939729 100644 --- a/src/core/Layout.ts +++ b/src/core/Layout.ts @@ -267,9 +267,12 @@ export class Layout { public _onChildAdded(pixiParent: Container): void { if (this.hasParent) return; + if (onChildAdded(this, pixiParent) === false) { + return; + } + this.hasParent = true; this.invalidateRoot(); - onChildAdded(this, pixiParent); } /** diff --git a/src/core/utils/sort-children.ts b/src/core/utils/sort-children.ts index e0faf5b..b3c139e 100644 --- a/src/core/utils/sort-children.ts +++ b/src/core/utils/sort-children.ts @@ -18,7 +18,7 @@ export function onChildAdded(layout: Layout, pixiParent: Container) { } if (!parentLayout) { - return; + return false; } // Detach from previous yoga parent if any @@ -31,17 +31,19 @@ export function onChildAdded(layout: Layout, pixiParent: Container) { const yogaIndex = computeYogaInsertionIndex(layout, pixiParent, overflowContainer); if (yogaIndex === -1) { - return; + return false; } // Fast append path if (yogaIndex === parentLayout.yoga.getChildCount()) { parentLayout.yoga.insertChild(layout.yoga, yogaIndex); - return; + return true; } parentLayout.yoga.insertChild(layout.yoga, yogaIndex); + + return true; } /**