From e62b11b94491f39f8dab08a797769c1d9f15dd27 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 12:40:08 +0000 Subject: [PATCH] owed by dialogs-w1: DialogHost::run opens a dialog take_child as its child (S-L156) --- crates/ui-panels/src/dialog/host.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/ui-panels/src/dialog/host.rs b/crates/ui-panels/src/dialog/host.rs index 9e4890ca2..79e703cc7 100644 --- a/crates/ui-panels/src/dialog/host.rs +++ b/crates/ui-panels/src/dialog/host.rs @@ -218,6 +218,7 @@ trait AnyStackDialog: Send { fn key(&self) -> Option; fn instance(&self) -> Option; fn confirm_erased(&mut self, ctx: &Context) -> Option>; + fn take_child_erased(&mut self) -> Option; fn held_state(&self) -> Option; fn canvas(&self) -> Option; fn json_fields(&self) -> Option; @@ -257,6 +258,10 @@ impl AnyStackDialog for D { self.confirm(ctx).map(|result| Box::new(DialogResult::Ok(result)) as Box) } + fn take_child_erased(&mut self) -> Option { + StackDialog::take_child(self) + } + fn held_state(&self) -> Option { StackDialog::held_state(self) } @@ -451,7 +456,13 @@ impl DialogHost { let Some(at) = self.position_by_id(id) else { continue }; let stack = &self.stack; let dialog = &mut self.open[at]; - let Some(result) = crate::runtime::overlay::stack_place(&ctx, place, id, || dialog.show_erased(ui, stack)) else { continue }; + let Some(result) = crate::runtime::overlay::stack_place(&ctx, place, id, || dialog.show_erased(ui, stack)) else { + // The dialog stays open: a child it asks for opens over it and shows from the next pass. + if let Some(ChildDialog(child)) = self.open[at].take_child_erased() { + self.open_with_parent(child, Some(id)); + } + continue; + }; self.remove_tree(id); let dialog = self.open.remove(at); crate::runtime::overlay::end_stack_dialog(&ctx, id);