diff --git a/crates/ui/src/resizable/panel.rs b/crates/ui/src/resizable/panel.rs index 08250154..dfb29a16 100644 --- a/crates/ui/src/resizable/panel.rs +++ b/crates/ui/src/resizable/panel.rs @@ -351,7 +351,8 @@ impl FluentBuilder for ResizablePanel {} impl Render for ResizablePanel { fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let view = cx.view().clone(); - + let total_size = self.group.as_ref().map(|group| group.read(cx).total_size()); + div() .flex() .flex_grow() @@ -366,9 +367,16 @@ impl Render for ResizablePanel { this.when(self.size.is_none(), |this| this.flex_shrink_0()) .flex_basis(size) }) - .when_some(self.size_ratio, |this, size_ratio| { - this.flex_basis(relative(size_ratio)) - }) + .map( + |this| match (self.size_ratio, self.size, total_size) { + (Some(size_ratio), _, _) => this.flex_basis(relative(size_ratio)), + (None, Some(size), Some(total_size)) => { + this.flex_basis(relative(size / total_size)) + } + (None, Some(size), None) => this.flex_basis(size), + _ => this, + }, + ) .child({ canvas( move |bounds, cx| view.update(cx, |r, cx| r.update_size(bounds, cx)),