Files
figcraft/crates/ui-egui/src/vector_panel_tests.rs
Rob CoenenandClaude Opus 5.5 9404226235 M4: vector edit mode keeps the canvas still under the pointer
With no points picked, the Design panel's hint ("Select points to edit
their position, radius and mirroring") didn't wrap and made the canvas
49 points wider, so entering vector edit mode moved the view by about 25
points and picking a region moved it back. The jump came in the middle
of the click that picked the region: with the smallest pointer movement
the release landed elsewhere on the page and the region was dragged by
that distance (about 47 units at 70%). Both edit mode hints now wrap.
Regression test: the canvas rectangle stays the same entering edit mode,
picking a region and switching to the width tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 12:35:06 -04:00

27 lines
1.4 KiB
Rust

//! The Design panel in vector edit mode keeps its width, so the canvas doesn't move under the
//! pointer when the panel's contents change.
use serde_json::json;
#[test]
fn the_canvas_stays_put_entering_vector_edit_mode_and_picking_a_region() {
let (mut h, _) = crate::live_tests::Harness::new();
h.app.session.execute("file.newFromTemplate", &json!({"template": "mobile-app"})).unwrap();
// A wide vector with a filled area: the panel shows its long hint until something is picked.
let id = {
let doc = h.app.session.doc().unwrap();
doc.nodes().filter(|n| n.name == "Near ridge").max_by(|a, b| a.height.total_cmp(&b.height)).map(|n| n.id).unwrap()
};
let canvas = |h: &mut crate::live_tests::Harness| {
h.frames(4);
h.app.inspect()["canvas"]["rect"].clone()
};
h.app.session.execute("select.set", &json!({"ids": [id.0]})).unwrap();
let before = canvas(&mut h);
h.app.session.execute("vector.edit.begin", &json!({})).unwrap();
assert_eq!(canvas(&mut h), before, "the hint for an empty point selection wraps instead of widening the panel");
h.app.session.execute("vector.edit.select", &json!({"regions": [0]})).unwrap();
assert_eq!(canvas(&mut h), before, "picking a region doesn't move the canvas either");
h.app.session.execute("vector.edit.tool", &json!({"tool": "width"})).unwrap();
assert_eq!(canvas(&mut h), before, "nor does the width tool's hint");
}