diff --git a/crates/ui-egui/src/dialogs/halftone.rs b/crates/ui-egui/src/dialogs/halftone.rs
index f09e9ad679..0ddd29b54b 100644
--- a/crates/ui-egui/src/dialogs/halftone.rs
+++ b/crates/ui-egui/src/dialogs/halftone.rs
@@ -59,7 +59,7 @@ pub(crate) fn screen_params(live: bool, fields: &DialogFields) -> Vec {
let styles =
[("custom", "Custom"), ("grid", "Grid"), ("gridAngle", "Grid Angle"), ("gridDots", "Grid Dots"), ("gridDotsAngle", "Grid Dots Angle")];
// A named style sets the shape and the angle, so their rows show only for Custom.
- let custom = fields.text("style").is_none_or(|s| s == "custom");
+ let custom = fields.text("style").is_none_or(|s| s.eq_ignore_ascii_case("custom"));
let mut rows = vec![Param::new("style", tl!("Style"), ParamKind::choice(options(&styles), Some("custom".into())))];
if custom {
rows.push(Param::new("shape", tl!("Shape"), ParamKind::choice(options(&shapes), Some("circle".into()))));
@@ -130,7 +130,7 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result {
/// Angle are left out so that the style's own shape and angle apply.
pub(crate) fn command_params(fields: &DialogFields) -> serde_json::Map {
let mut params = json_of(&screen_params(false, fields), fields);
- if params.get("style").and_then(Value::as_str).is_some_and(|s| s != "custom") {
+ if params.get("style").and_then(Value::as_str).is_some_and(|s| !s.eq_ignore_ascii_case("custom")) {
params.remove("shape");
params.remove("angle");
}
@@ -310,6 +310,20 @@ mod tests {
}
}
+ /// A stored style matches Custom in any letter case, as the effect reads it, so Shape and
+ /// Angle stay on screen and OK sends both.
+ #[test]
+ fn custom_style_in_any_case_keeps_shape_and_angle() {
+ let mut values = fields();
+ values["style"] = json!("CUSTOM");
+ let f = fields_of(&screen_params(false, &DialogFields::new()), values.as_object().unwrap());
+ let rows = screen_params(false, &f);
+ let shown = |k: &str| rows.iter().any(|p| p.key == k);
+ assert!(shown("shape") && shown("angle"), "Shape and Angle rows are hidden");
+ let sent = command_params(&f);
+ assert!(sent.contains_key("shape") && sent.contains_key("angle"), "{sent:?}");
+ }
+
/// With Preview off, OK after File > Revert is refused and leaves the restored drawing as it is.
#[test]
fn vector_halftone_without_preview_refuses_ok_after_file_revert() {