From 8731bf1f7edb7ca8a2bfe04bdd446649520bfd73 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Mon, 22 Apr 2024 09:48:32 +0200 Subject: [PATCH] Fix order --- src/elements/grid.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/elements/grid.rs b/src/elements/grid.rs index 90fa6ad..717cd39 100644 --- a/src/elements/grid.rs +++ b/src/elements/grid.rs @@ -361,6 +361,19 @@ impl Grid { child_gridable.set_layer(self.framable.ui_layer())?; } + // disable the old element + match &grid[pos_x][pos_y] { + ChildState::Some { child, .. } => { + if self.visible() { + if let Some(child_visibility) = child.visibility() { + child_visibility.set_visibility(false)?; + } + } + } + ChildState::Extend { .. } => todo!(), + ChildState::None => (), + } + if self.visible() { if let Some(child_visibility) = child.visibility() { child_visibility.set_visibility(true)?; @@ -375,19 +388,6 @@ impl Grid { let weak = child_state.downgrade(); - // disable the old element - match &grid[pos_x][pos_y] { - ChildState::Some { child, .. } => { - if self.visible() { - if let Some(child_visibility) = child.visibility() { - child_visibility.set_visibility(false)?; - } - } - } - ChildState::Extend { .. } => todo!(), - ChildState::None => (), - } - // insert the element for x in pos_x..(pos_x + dim_x as usize) { for y in pos_y..(pos_y + dim_y as usize) {