From c523a4c48ad4daa20bc184dbb28f1b21732e2fdc Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:21:39 -0400 Subject: [PATCH] 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. --- crates/ui-egui/src/lib.rs | 3 +++ crates/ui-egui/tests/it/macro_editor.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index db8e3d19e..8e6155bee 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -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), } } diff --git a/crates/ui-egui/tests/it/macro_editor.rs b/crates/ui-egui/tests/it/macro_editor.rs index 8e7db5206..8c3b07cc1 100644 --- a/crates/ui-egui/tests/it/macro_editor.rs +++ b/crates/ui-egui/tests/it/macro_editor.rs @@ -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")); +}