From 8f58c39bd740901bc70aab798d2badf76fb81d7c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Thu, 15 Oct 2026 19:12:26 +0700 Subject: [PATCH] #352: keep the highlighted font in view in a shorter list Where the window has less room the font list is shorter than its tallest, and stepping down left the highlighted row cut off at the bottom. The scroll now uses the list's height as last drawn. --- crates/ui-egui/src/typography.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/typography.rs b/crates/ui-egui/src/typography.rs index 0d9d3b8b..35f6df76 100644 --- a/crates/ui-egui/src/typography.rs +++ b/crates/ui-egui/src/typography.rs @@ -1161,10 +1161,11 @@ pub(crate) fn font_picker(ui: &mut Ui, current: Option<&str>, just_opened: bool) } } if let Some(i) = hi { - // Scrolled just enough to show it. - let seen: f32 = ui.data(|d| d.get_temp(hi_id.with("offset"))).unwrap_or(0.0); + // Scrolled just enough to show it (the list is shorter than its tallest where the + // window has less room). + let (seen, height): (f32, f32) = ui.data(|d| d.get_temp(hi_id.with("view"))).unwrap_or((0.0, LIST_HEIGHT)); let top = i as f32 * stride; - offset = Some(seen.max(top + stride - LIST_HEIGHT).min(top)); + offset = Some(seen.max(top + stride - height).min(top)); } } match hi { @@ -1231,7 +1232,7 @@ pub(crate) fn font_picker(ui: &mut Ui, current: Option<&str>, just_opened: bool) } } }); - ui.data_mut(|d| d.insert_temp(hi_id.with("offset"), shown.state.offset.y)); + ui.data_mut(|d| d.insert_temp(hi_id.with("view"), (shown.state.offset.y, shown.inner_rect.height()))); FontPick { highlighted: hi.and_then(family), picked } }