From 01bbc0aa9fa3a3d01ed49be0a9f171beeb72f6ae Mon Sep 17 00:00:00 2001 From: dudedagger42 <76926918+dudedagger42@users.noreply.github.com> Date: Fri, 23 Oct 2026 13:43:26 +0000 Subject: [PATCH] Parameters: a favourite renames by double-click (#4952) (#5070) A favourite is listed twice, under Favourites and under User. Double-clicking its name opened a name editor in both rows, under one widget id; the two took each other's focus, one lost it at once, and the rename closed with the name unchanged. The rename now opens only in the table it was started in, under an id that includes that table. Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/manage_dialogs_tests.rs | 10 ++++++++++ crates/ui-egui/src/params_dialog.rs | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/manage_dialogs_tests.rs b/crates/ui-egui/src/manage_dialogs_tests.rs index 7b6db3f81..7f528eac6 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.rs index 604ed9b2d..f797afe86 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, /// 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: &[&R crate::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(); } } });