Skip to content

Commit

Permalink
panel: To keep panel size when it going to hidden.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Dec 20, 2024
1 parent c8fae22 commit 27c779e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/ui/src/resizable/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,17 @@ impl ResizablePanel {
/// Save the real panel size, and update group sizes
fn update_size(&mut self, bounds: Bounds<Pixels>, cx: &mut ViewContext<Self>) {
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;
}
});
Expand All @@ -361,6 +361,9 @@ impl FluentBuilder for ResizablePanel {}
impl Render for ResizablePanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> 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();
}

Expand Down

0 comments on commit 27c779e

Please sign in to comment.