diff --git a/crates/ui/src/resizable/panel.rs b/crates/ui/src/resizable/panel.rs index 2669f47a..a8d71f74 100644 --- a/crates/ui/src/resizable/panel.rs +++ b/crates/ui/src/resizable/panel.rs @@ -337,17 +337,17 @@ impl ResizablePanel { /// Save the real panel size, and update group sizes fn update_size(&mut self, bounds: Bounds, cx: &mut ViewContext) { let new_size = bounds.size.along(self.axis); + if self.size == Some(new_size) { + return; + } + self.bounds = bounds; self.size = Some(new_size); - let panel_view = cx.view().clone(); + let entity_id = cx.view().entity_id(); if let Some(group) = self.group.as_ref() { _ = group.update(cx, |view, _| { - if let Some(ix) = view - .panels - .iter() - .position(|v| v.entity_id() == panel_view.entity_id()) - { + if let Some(ix) = view.panels.iter().position(|v| v.entity_id() == entity_id) { view.sizes[ix] = new_size; } }); @@ -361,6 +361,9 @@ impl FluentBuilder for ResizablePanel {} impl Render for ResizablePanel { fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { if !(self.content_visible)(cx) { + // To keep size as initial size, to make sure the size will not be changed. + self.initial_size = self.size; + self.size = None; return div(); }