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 <noreply@anthropic.com>
This commit is contained in:
1 parent
dbbad6d4ee
commit
01bbc0aa9f
2 files changed
+17
-2
No files matched your search
@@ -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");
|
||||
|
||||
@@ -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: &[&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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user