From d9ea057da7515d9c04cf4b7e62287edea50c7f22 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Fri, 2 Oct 2026 02:18:47 -0700 Subject: [PATCH] fix: the sidebar opens on its folds as they stand Every notebook and section group eased open from nothing each time the sidebar opened, and again as a notebook's sections arrived, because the rows' height was unknown on the frame they first showed. Rows that appear with the tree now show at once, open or folded as they were left; only folding or unfolding one eases. Assisted-by: claude-opus-5.5 --- crates/snowbound/src/sidebar.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/snowbound/src/sidebar.rs b/crates/snowbound/src/sidebar.rs index 075a04ec9015a144aa3c947ed55bbce8d0f3058b..3ca4b59288b9c485a3921f7167b5b2794e972955 100644 --- a/crates/snowbound/src/sidebar.rs +++ b/crates/snowbound/src/sidebar.rs @@ -538,22 +538,31 @@ fn gap(ui: &mut Ui, tree: &mut Tree, folder: &str, before: Option<&str>) { } /// Opens the boxes a notebook's or group's rows ease open and shut in, where they show: -/// the caller builds the rows and closes both. +/// the caller builds the rows and closes both. Rows appearing with the tree, as the sidebar +/// opens or a notebook's sections arrive, show as they stand; only a toggle eases. fn unfolding(ui: &mut Ui, part: impl std::hash::Hash, unfolded: bool) -> bool { let outer = ui.id(part); - let rows = ui - .rect(outer.child("rows")) - .map_or(0.0, |rect| rect[3] - rect[1]); - let height = ui.animate(outer, if unfolded { rows } else { 0.0 }); - if !unfolded && height == 0.0 { - return false; - } + let height = if ui.lasted(outer.child("shown"), true).is_zero() { + if !unfolded { + return false; + } + ui::children() + } else { + let rows = ui + .rect(outer.child("rows")) + .map_or(0.0, |rect| rect[3] - rect[1]); + let height = ui.animate(outer, if unfolded { rows } else { 0.0 }); + if !unfolded && height == 0.0 { + return false; + } + px(height) + }; ui.open_as( outer, Spec { flags: Flags::CLIP, axis: Axis::Y, - size: [fill(), px(height)], + size: [fill(), height], ..Spec::default() }, ); -- 2.54.0