dialogs-w2: ColorPickerDialog is a registered pattern (its tabbed stories link); DIAG on the tabbed hex answer

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Martin Ball
2026-11-18 18:33:59 +00:00
co-authored by Claude Sonnet 5.5
parent 4a4ede4caa
commit c38e059359
2 changed files with 19 additions and 0 deletions
+9
View File
@@ -136,6 +136,7 @@ enum Title {
/// the app takes the colour with [`take_add_to_swatches`](Self::take_add_to_swatches).
/// - **Preview:** [`current`](Self::current) follows every edit, so an app that previews reads it each pass through
/// `DialogHost::get_by_id` and shows it live; Cancel is the app's cue to put the old colour back.
#[derive(craft_ui::contract::Pattern)]
pub struct ColorPickerDialog {
id: DialogId,
/// Which of several pickers of the same key this is ([`instance`](Self::instance)).
@@ -658,6 +659,14 @@ impl StackDialog for ColorPickerDialog {
}
});
self.current = held.same().copied();
if self.layout == ColorPickerDialogLayout::Tabbed {
eprintln!(
"DIAG the_tabbed_colors_dialog_opens_on_its_tab_and_answers_from_either_page: held same={} picked={:?} closed={:?}",
self.current.is_some(),
shown.output.picked,
shown.output.closed
);
}
let (picked, closed) = (shown.output.picked, shown.output.closed);
let ok = (picked == Some(0) || closed == Some(CloseReason::Enter)) && self.current.is_some();
+10
View File
@@ -210,7 +210,17 @@ fn the_tabbed_colors_dialog_opens_on_its_tab_and_answers_from_either_page() {
assert_eq!(dialog_field(&dialogs, "model"), Some(serde_json::json!(RgbModel.id())), "the field names the model shown");
assert!(fixture.by_label("Red").is_some(), "and the compact rows show that model's channels");
eprintln!(
"DIAG the_tabbed_colors_dialog_opens_on_its_tab_and_answers_from_either_page: before typing current={:?} open={}",
dialog_color(&dialogs),
dialogs.borrow().get::<ColorPickerDialog>().is_some()
);
type_into(&mut fixture, "Hex color", "336699");
eprintln!(
"DIAG the_tabbed_colors_dialog_opens_on_its_tab_and_answers_from_either_page: after typing current={:?} open={}",
dialog_color(&dialogs),
dialogs.borrow().get::<ColorPickerDialog>().is_some()
);
assert_eq!(dialog_color(&dialogs).as_deref(), Some("#336699"), "a hex typed on Custom is the colour");
let set = dialogs.borrow_mut().set_json_field(&ctx, id, "tab", serde_json::json!("standard"));