From 9ce5ffd244deb1a8179696f0a36610c8eee3aa6b Mon Sep 17 00:00:00 2001 From: Rahul Ranjan <11793455+rahul05ranjan@users.noreply.github.com> Date: Tue, 20 Oct 2026 14:30:17 +0530 Subject: [PATCH] Offset Path's Preview checkbox keeps its last state across opens (#3195) The Offset Path dialog remembers the values it was last confirmed with (#1152), but the Preview checkbox was not among the kept fields, so every open started unchecked and Preview had to be ticked manually each time. Preview now rides along with offset, joins and miterLimit in the fields kept on OK, as Simplify's retained fields already keep theirs. Unchanged: a very first open (nothing kept yet) still starts unchecked, and Cancel keeps nothing. Adds a regression test beside offset_path_remembers_its_last_values: open, tick Preview, confirm, reopen - the checkbox is still on. Verified by reading the flow on current main (menus.rs opens on app.ui.offset_path when it is an object, d.bool("preview") defaults to false when the field is absent, form::preview_result ticks the checkbox into d.fields) and by tracing the existing #1152 test; no Rust toolchain on this machine, so the test was not executed here - saying so plainly for the reviewer. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com> --- crates/ui-egui/src/dialogs/path_ops.rs | 4 +++- crates/ui-egui/src/dialogs/tests_modal.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/path_ops.rs b/crates/ui-egui/src/dialogs/path_ops.rs index c46096a00..b3197b5cb 100644 --- a/crates/ui-egui/src/dialogs/path_ops.rs +++ b/crates/ui-egui/src/dialogs/path_ops.rs @@ -193,7 +193,9 @@ fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result { } // The fields as the dialog held them, so they show as typed when it opens again. if d.kind == "offsetPath" { - let kept = ["offset", "joins", "miterLimit"].into_iter().filter_map(|k| Some((k.to_string(), d.fields.get(k)?.clone()))); + // Preview among them: the checkbox keeps its last state across opens (#3195), as + // Simplify's retained fields keep theirs. + let kept = ["offset", "joins", "miterLimit", "preview"].into_iter().filter_map(|k| Some((k.to_string(), d.fields.get(k)?.clone()))); app.ui.offset_path = Value::Object(kept.collect()); } Ok(r) diff --git a/crates/ui-egui/src/dialogs/tests_modal.rs b/crates/ui-egui/src/dialogs/tests_modal.rs index 883194916..6008b0724 100644 --- a/crates/ui-egui/src/dialogs/tests_modal.rs +++ b/crates/ui-egui/src/dialogs/tests_modal.rs @@ -284,6 +284,21 @@ fn offset_path_remembers_its_last_values() { assert_eq!((d.f64("offset", 0.0), d.str("joins"), d.f64("miterLimit", 0.0)), (-4.5, "round".to_string(), 4.0)); } +/// Offset Path's Preview checkbox keeps its last state across opens, like the other fields (#3195). +#[test] +fn offset_path_remembers_its_last_preview_state() { + let mut app = app_with_selection(); + app.run("select.all", json!({})).unwrap(); + crate::menus::invoke(&mut app, "object.path.offsetPath", json!({})); + let d = app.ui.dialog.as_mut().unwrap(); + assert!(!d.bool("preview"), "a first open is unchecked"); + d.fields.insert("preview".into(), json!(true)); + confirm(&mut app).unwrap(); + crate::menus::invoke(&mut app, "object.path.offsetPath", json!({})); + let d = app.ui.dialog.as_ref().unwrap(); + assert!(d.bool("preview"), "the state it was confirmed with"); +} + fn app_with_dense_path() -> VectorcraftApp { let mut app = VectorcraftApp::new(Session::new(), Default::default()); app.run("file.new", json!({"width": 400, "height": 300})).unwrap();