mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-30 05:37:00 -06:00
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:
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user