From 6f83a8d16447b2590cb081f3e0f294678cc6caaf Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 5 Jul 2024 13:45:42 -0400 Subject: [PATCH] fix(core): state order and handling of new trees --- core/src/widget/tree.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/widget/tree.rs b/core/src/widget/tree.rs index f1b37114b2..078a64d164 100644 --- a/core/src/widget/tree.rs +++ b/core/src/widget/tree.rs @@ -76,7 +76,7 @@ impl Tree { let state = mem::replace(&mut tree.state, State::None); let children_count = tree.children.len(); let children = - tree.children.iter_mut().rev().enumerate().map(|(i, c)| { + tree.children.iter_mut().enumerate().rev().map(|(i, c)| { if matches!(c.id, Some(Id(Internal::Custom(_, _)))) { (c, None) } else { @@ -350,7 +350,11 @@ impl Tree { } for (new_tree, i) in new_trees { - self.children.insert(i, new_tree); + if self.children.len() > i { + self.children[i] = new_tree; + } else { + self.children.push(new_tree); + } } } }