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 <noreply@anthropic.com>
This commit is contained in:
Trevor BrownandClaude Opus 5.5 committed 2026-11-14 04:37:56 -05:00
1 parent 5a482af812
commit 29fe911dd9
2 files changed
+21 -1

No files matched your search

@@ -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));
@@ -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();