diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index fdaaebcee1..6a70094ac2 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -1,6 +1,8 @@ //! Panel bodies: what the dock area ([`crate::panel_docking`]) draws inside a docked, floating or //! flyout panel. +use craft::ui::contract::{Props as _, Scroll, ShowContainer as _}; +use craft::ui::layout_components::Stack; use egui::Ui; use crate::state::DockTab; @@ -13,6 +15,14 @@ pub(crate) fn panel_body(app: &mut VectorcraftApp, ui: &mut Ui, id: &str) { Some(DockTab::Properties) => panels::properties::show(app, ui), Some(DockTab::Layers) => panels::layers::show(app, ui), Some(DockTab::Libraries) => panels::libraries(app, ui), - None => panels::show_icon_panel(app, ui, id), + None => { + // The dock clips the group at its assigned height. Keep the panel's own collection + // viewport bounded while allowing a form that exceeds that height to scroll. + let height = ui.available_height(); + Stack::new().id_salt(id).fill().scroll(Scroll::vertical()).show(ui, |ui, _| { + ui.set_max_height(height); + panels::show_icon_panel(app, ui, id); + }); + } } } diff --git a/crates/ui-egui/src/panels/pattern_options.rs b/crates/ui-egui/src/panels/pattern_options.rs index e811df4c17..7b7494b48a 100644 --- a/crates/ui-egui/src/panels/pattern_options.rs +++ b/crates/ui-egui/src/panels/pattern_options.rs @@ -267,6 +267,26 @@ mod tests { Panel::new(app, show) } + #[test] + fn scrolling_a_short_docked_form_reaches_its_last_action() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); + app.run("object.pattern.make", json!({"name": "Dots"})).unwrap(); + let mut panel = Panel::new(app, |app, ui| crate::dock::panel_body(app, ui, "patternOptions")); + panel.room(egui::vec2(300.0, 200.0)); + panel.frame(); + panel.frame(); + assert!(!panel.in_view("Done")); + for _ in 0..20 { + panel.scroll_at(egui::pos2(150.0, 100.0), -120.0); + panel.frame(); + } + assert!(panel.in_view("Done")); + panel.click("Done"); + assert!(editing(&panel.app()).is_none()); + } + /// Shift+Enter in the Name field renames the pattern and keeps the field active; Enter then /// renames it again and ends the editing. #[test]