From 29fe911dd937cb963b4d144606f06bda280318f3 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sat, 14 Nov 2026 04:37:56 -0500 Subject: [PATCH] M3: on a short screen the Local variables window's body takes what is left (#2354) The body below the header had a 160-point floor, so with the minimum capped by a screen lower than 220 points the content ran past the window. It now takes the height left below the header (the table scrolls). Test on_a_short_screen_the_variables_window_fits_inside_it (red before: the window ran to y 206 on a 180-high screen); variables 45 passed, clippy clean (CodeRabbit on #2363). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/dialogs/variables_panel.rs | 3 ++- .../src/variables_window_resize_tests.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/variables_panel.rs b/crates/ui-egui/src/dialogs/variables_panel.rs index d018e7f2f..233181fb7 100644 --- a/crates/ui-egui/src/dialogs/variables_panel.rs +++ b/crates/ui-egui/src/dialogs/variables_panel.rs @@ -294,7 +294,8 @@ pub fn show(app: &mut FigApp, ctx: &Context) { ui.set_min_size(size); ui.spacing_mut().item_spacing = vec2(0.0, 0.0); header(app, ui, &mut open); - let h = (size.y - 44.0).max(160.0); + // The body below the 44-point header: what is left of the window (the table scrolls). + let h = (size.y - 44.0).max(0.0); let top_down = egui::Layout::top_down(egui::Align::Min); ui.horizontal_top(|ui| { ui.allocate_ui_with_layout(vec2(SIDEBAR_W, h), top_down, |ui| sidebar(app, ui, &views, &doc.variables, &mut st)); diff --git a/crates/ui-egui/src/variables_window_resize_tests.rs b/crates/ui-egui/src/variables_window_resize_tests.rs index e2dedae75..8ec2c4113 100644 --- a/crates/ui-egui/src/variables_window_resize_tests.rs +++ b/crates/ui-egui/src/variables_window_resize_tests.rs @@ -76,6 +76,25 @@ fn on_a_narrow_screen_the_variables_window_fits_inside_it() { assert!(screen.contains_rect(r), "the window {r:?} is inside the screen {screen:?}"); } +#[test] +fn on_a_short_screen_the_variables_window_fits_inside_it() { + // Lower than the minimum (240): the body takes what is left below the header and scrolls. + let mut s = Session::new(); + s.execute("variable.createCollection", &json!({"name": "Theme"})).unwrap(); + for k in 0..COUNT { + s.execute("variable.create", &json!({"collection": "Theme", "name": format!("v{k:02}"), "type": "number", "value": 1})).unwrap(); + } + let mut u = Ui::new(s); + u.screen = vec2(800.0, 180.0); + u.app.ui.variables = Some(Default::default()); + for _ in 0..10 { + u.frame(vec![]); + } + let r = rect(&u); + let screen = Rect::from_min_size(Pos2::ZERO, u.screen); + assert!(screen.contains_rect(r), "the window {r:?} is inside the screen {screen:?}"); +} + #[test] fn the_variables_window_keeps_a_minimum_size() { let mut u = window();