Fill: picker OK writes the colour into Fill at once (#17470)

Without a Color row, the picker's answer reached Fill only in the next dialog
pass, so a Fill OK right after the picker's OK (an agent's next request, or
framework_dialog_dropper_keeps_native_model_values) filled with the old
colour and the new inks did not match it. The picker's OK now writes the
colour into its parent's field with the inks, keeping a row's opacity.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-12-01 12:31:34 +01:00
1 parent 99f90205c3
commit e6fe79fe3c
2 files changed
+23

No files matched your search

@@ -424,6 +424,14 @@ fn commit(app: &mut PhotocraftApp, _id: DialogId, target: PickTarget, picked: &P
PickTarget::NewSolidFill { document } => crate::solid_fill_ui::confirm_new(app, *document, picked),
PickTarget::Request { parent, key } => {
if let Some(dialog) = app.framework.dialogs.get_mut_by_id::<HostedParamDialog>(*parent) {
// The colour goes in with its inks at once, so an OK of the parent right after this one (an agent's next
// request, before a dialog pass has taken the answer) fills with it; a row with opacity keeps its own.
let [r, g, b] = picked.color.to_rgb_array();
let value = match dialog.fields().get(key) {
Some(FieldValue::Rgba([.., a])) => FieldValue::Rgba([r, g, b, *a]),
_ => FieldValue::Color([r, g, b]),
};
dialog.set_field(key.clone(), value);
dialog.set_field(ink_field(key), ink_value(picked.color, inks_of(picked)));
}
app.color_answers.push((*parent, key.clone(), picked.color));
@@ -163,3 +163,18 @@ fn picker_cancel_from_foreground_fills_with_the_remembered_colour() {
let [r, g, b, _] = pixel(&h);
assert!(close([r, g, b], rgb(BLUE)), "Fill OK fills with the remembered colour: {:?}", pixel(&h));
}
/// Fill OK straight after picker OK, with no dialog pass between them (an agent's two requests), fills with the picked
/// colour: the picker writes it into Fill at once.
#[test]
fn fill_ok_right_after_picker_ok_fills_with_the_picked_colour() {
let mut h = harness();
let fill = open_fill(&mut h);
let id = choose_color(&mut h).expect("the picker opens");
picker::set_color(h.state_mut(), id, GREEN);
confirm(h.state_mut(), id).unwrap();
confirm(h.state_mut(), fill).unwrap();
h.run_steps(3);
let [r, g, b, _] = pixel(&h);
assert!(close([r, g, b], rgb(GREEN)), "Fill OK fills with the picked colour: {:?}", pixel(&h));
}