From e70cbffa4882f0f83e638d67b2ffe412fb549195 Mon Sep 17 00:00:00 2001 From: Starmapo Date: Thu, 5 Sep 2024 16:06:04 -0400 Subject: [PATCH] Fix components not being spliced from the state when removed --- haxe/ui/backend/ScreenImpl.hx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/haxe/ui/backend/ScreenImpl.hx b/haxe/ui/backend/ScreenImpl.hx index 49e578b..4d51fe2 100644 --- a/haxe/ui/backend/ScreenImpl.hx +++ b/haxe/ui/backend/ScreenImpl.hx @@ -233,14 +233,17 @@ class ScreenImpl extends ScreenBase { if (rootComponents.indexOf(component) != -1) { throw "component wasnt actually removed from array, or there is a duplicate in the array"; } + if (StateHelper.currentState.exists == true) { + StateHelper.currentState.remove(component, true); + } + // Destroying a sprite makes it get removed from its container (in this case, the state) without + // being spliced, causing issues later with `addComponent()` not actually adding components on top + // of everything else, so this has to go after the component has been properly removed. if (dispose) { component.disposeComponent(); } else { component.applyRemoveInternal(); } - if (StateHelper.currentState.exists == true) { - StateHelper.currentState.remove(component, true); - } checkResetCursor(); onContainerResize(); return component;