From 6a2dc3614076e42083de27c9bdb5dccbf26fedcb Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 7 May 2024 20:11:58 -0400 Subject: [PATCH] Fix ContainerBox child insertion --- containerbox.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/containerbox.go b/containerbox.go index de2df3f..377361d 100644 --- a/containerbox.go +++ b/containerbox.go @@ -119,10 +119,14 @@ func (this *containerBox) Insert (child, before tomo.Object) { beforeBox := assertAnyBox(before.GetBox()) index := indexOf(this.children, tomo.Box(beforeBox)) - if index < 0 { return } - + + if index < 0 { + this.children = append(this.children, tomo.Box(box)) + } else { + this.children = insert(this.children, index, tomo.Box(box)) + } box.setParent(this) - this.children = insert(this.children, index, tomo.Box(box)) + this.invalidateLayout() this.invalidateMinimum() }