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