From fe7701007c61816fc2daa4986d9c9ba4399b1ebd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 22 Nov 2026 04:18:43 -0500 Subject: [PATCH] Dialog: Close in place of OK and Cancel while the fields are unchanged (L-307) --- .../ui-contract/src/runtime/words/common.rs | 2 + crates/ui-panels/src/dialog/modal.rs | 38 ++++++++++++++++++- crates/ui-panels/src/dialog/trials.rs | 29 ++++++++++++++ .../src/patterns/form_dialogs/dialog.rs | 7 ++++ .../src/patterns/form_dialogs/form.rs | 12 ++++++ .../tests/it/form_dialogs/document_layout.rs | 18 +++++++++ 6 files changed, 104 insertions(+), 2 deletions(-) diff --git a/crates/ui-contract/src/runtime/words/common.rs b/crates/ui-contract/src/runtime/words/common.rs index 6e2754a64..63ca79ca8 100644 --- a/crates/ui-contract/src/runtime/words/common.rs +++ b/crates/ui-contract/src/runtime/words/common.rs @@ -7,6 +7,8 @@ craft_ui::words! { pub struct CommonWords { cancel: "common.cancel" = "Cancel"; ok: "common.ok" = "OK"; + /// The button of a dialog whose fields are unchanged, in place of OK and Cancel. + close: "common.close" = "Close"; dont_show_again: "common.dontShowAgain" = "Don't show again"; /// The tooltip of a label's reset dot. reset_to_default: "common.resetToDefault" = "Reset to default"; diff --git a/crates/ui-panels/src/dialog/modal.rs b/crates/ui-panels/src/dialog/modal.rs index c4f409f6d..59577f382 100644 --- a/crates/ui-panels/src/dialog/modal.rs +++ b/crates/ui-panels/src/dialog/modal.rs @@ -2,6 +2,7 @@ //! focus trap, placement and size remembered under a `SaveKey`. use super::frame::{self, DialogOutput, FOOTER, FooterCx, FooterFn, FooterHooks, HEADER, SIDE_BUTTONS}; +use crate::contract::Remember as _; use crate::contract::overlay::{FloatPlace, OverlayFit, Place}; use crate::contract::{ Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, Cx, DragBand, FooterPlace, FooterRegion, HeaderRegion, Mount, Overlay, Pad, @@ -9,7 +10,8 @@ use crate::contract::{ }; use crate::edit::outer::{self, OuterEnd}; use crate::runtime::access::Access; -use crate::runtime::env::Label; +use crate::runtime::env::{Env, Label}; +use crate::runtime::words::CommonWords; use crate::runtime::focus::Initial; use crate::runtime::memory::sub; use crate::runtime::overlay::{self, Backdrop, CloseReason, Rank}; @@ -82,6 +84,10 @@ pub struct Dialog<'a> { title_note: Option