SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Parameters: a favourite renames by double-click (#4952) (#5070)
dudedagger4201bbc0aa9fa3
diff --git a/crates/ui-egui/src/manage_dialogs_tests.rs b/crates/ui-egui/src/manage_dialogs_tests.rsindex 7b6db3f814..7f528eac61 100644--- a/crates/ui-egui/src/manage_dialogs_tests.rs+++ b/crates/ui-egui/src/manage_dialogs_tests.rs@@ -330,6 +330,16 @@ fn parameter_inventory_remains_reachable_with_regular_draft_rows() {h.step(&json!({"click":{"handle":"param:star:span"}})).unwrap();assert!(h.widget("Favorites").is_some());assert!(scenario::handle_at("param:favorite:span").is_some());+ // #4952: a favourite, listed under Favourites and User, renames by double-click too (two+ // editors on one name took each other's focus and the rename closed at once).+ h.frames(40);+ h.step(&json!({"click":{"handle":"param:name:span"},"double":true})).unwrap();+ h.frames(4);+ assert!(h.app.params.as_ref().unwrap().renaming.is_some(), "the favourite's rename stays open");+ h.step(&json!({"key":"A","cmd":true})).unwrap();+ h.step(&json!({"text":"breadth"})).unwrap();+ h.step(&json!({"key":"Enter"})).unwrap();+ assert!(h.app.session.doc.param("breadth").is_some(), "a favourite renames by double-click");h.step(&json!({"click":{"handle":"dialog:cancel"}})).unwrap();assert!(h.app.params.is_none());assert!(h.app.session.doc.param("pitch").is_some(), "Cancel keeps committed edits");diff --git a/crates/ui-egui/src/params_dialog.rs b/crates/ui-egui/src/params_dialog.rsindex 604ed9b2d3..f797afe86d 100644--- a/crates/ui-egui/src/params_dialog.rs+++ b/crates/ui-egui/src/params_dialog.rs@@ -29,6 +29,9 @@ pub struct ParamsDialog {pub comments: std::collections::BTreeMap<String, String>,/// A parameter being renamed: (old name, new name).pub renaming: Option<(String, String)>,+ /// The table the rename was started in. A favourite is listed twice (Favourites and User),+ /// and two editors on one name took each other's focus, so the rename closed at once (#4952).+ pub rename_table: String,pub new_name: String,pub adding: bool,pub focus_new: bool,@@ -339,9 +342,10 @@ fn table(app: &mut SolveApp, ui: &mut egui::Ui, d: &mut ParamsDialog, rows: &[&R}}});+ let renaming_here = d.rename_table == salt;row.cell(|ui| match &mut d.renaming {- Some((old, new)) if *old == r.name => {- let id = ui.make_persistent_id(("rename", &r.name));+ Some((old, new)) if *old == r.name && renaming_here => {+ let id = ui.make_persistent_id(("rename", salt, &r.name));let focused = ui.memory(|m| m.has_focus(id) || m.had_focus_last_frame(id));let response = ui_kit::cell_editor(ui, id, new, "Name", false);let entered = enter_for(ui, focused);@@ -361,6 +365,7 @@ fn table(app: &mut SolveApp, ui: &mut egui::Ui, d: &mut ParamsDialog, rows: &[&Rcrate::scenario::publish_handle(&format!("param:name:{}", r.name), response.rect.center());if response.double_clicked() {d.renaming = Some((r.name.clone(), r.name.clone()));+ d.rename_table = salt.to_string();}}});