Scroll overflowing panel forms inside their dock group

(cherry picked from commit a6c530518a)
This commit is contained in:
Codex committed 2026-11-30 15:36:25 +01:00
1 parent 8bacfd4cfa
commit 3a568c2011
2 files changed
+31 -1

No files matched your search

+11 -1
View File
@@ -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);
});
}
}
}
@@ -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]