UI: another dialog never replaces the open macro step editor

The step editor lives in the app's one dialog slot, so Format Cells, the Macros
dialog or New Macro opened while it was up took its place. The draft was lost
(New Macro started a fresh one), and a closed-over editor left its grid overlays and
its debug run behind. While the editor is open, requests for other dialogs are now
ignored; the editor closes itself as before.
This commit is contained in:
prxnvt
2026-10-25 06:48:57 -04:00
parent eb7b2b93f4
commit c523a4c48a
2 changed files with 19 additions and 0 deletions
+3
View File
@@ -826,6 +826,9 @@ impl SheetApp {
let page = params.get("page").and_then(Json::as_str).and_then(backstage::Page::parse).unwrap_or(backstage::Page::Home);
self.open_backstage(page);
}
// The macro step editor stays until it closes itself (its draft, overlays and debug
// run go with it), so another dialog can't replace it.
_ if self.dialog.as_ref().is_some_and(|d| d.name == "macroEditor") => {}
other => self.dialog = dialogs::Dialog::open(self, other, params),
}
}
+16
View File
@@ -269,3 +269,19 @@ fn a_rename_that_lands_before_a_failed_save_is_remembered() {
assert_eq!(wb.macros.len(), 1);
assert_eq!((wb.macros[0].name.as_str(), wb.macros[0].steps.len()), ("Renamed", 3));
}
#[test]
fn another_dialog_never_replaces_the_open_editor() {
let mut h = harness();
three(&mut h);
h.state_mut().macros.editor.as_mut().unwrap().draft.name = "Unsaved".into();
h.run_steps(2);
for name in ["formatCells", "macros", "macroEditor"] {
h.state_mut().open_dialog(name, json!({}));
h.run_steps(2);
assert_eq!(h.state().dialog.as_ref().map(|d| d.name.as_str()), Some("macroEditor"), "{name}");
assert_eq!(h.state().macros.editor.as_ref().map(|e| e.draft.name.as_str()), Some("Unsaved"), "{name}");
}
click(&mut h, "New Macro");
assert_eq!(h.state().macros.editor.as_ref().map(|e| e.draft.name.as_str()), Some("Unsaved"));
}