From edcc801a9cf4978be56682425df7c4901b1608ee Mon Sep 17 00:00:00 2001 From: x-labb <154824493+x-labb@users.noreply.github.com> Date: Wed, 28 Oct 2026 16:39:45 +0100 Subject: [PATCH] Issue #2980: Clear Color Label's toast ignores a label parameter photo.clearLabel takes no colour, but the toast code read params[label] for it as for photo.label, so photo.clearLabel {label: red} cleared the photo and showed 'Red Label'. The colour is read for photo.label only. --- crates/ui-egui/src/app.rs | 3 ++- crates/ui-egui/src/shortcuts/tests_clear_label.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 0b2685e59..b7f45fe15 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -252,7 +252,8 @@ impl LightcraftApp { } } if r.is_ok() && matches!(id, "photo.label" | "photo.clearLabel") { - let label = params.get("label").and_then(Value::as_str).and_then(lightcraft_catalog::ColorLabel::parse); + // Clear Color Label takes no colour: whatever `label` it is given, the photo's label is cleared + let label = params.get("label").and_then(Value::as_str).and_then(lightcraft_catalog::ColorLabel::parse).filter(|_| id == "photo.label"); let text = match label { Some(label) => { let name = diff --git a/crates/ui-egui/src/shortcuts/tests_clear_label.rs b/crates/ui-egui/src/shortcuts/tests_clear_label.rs index 2c3db87a4..f1ea73eff 100644 --- a/crates/ui-egui/src/shortcuts/tests_clear_label.rs +++ b/crates/ui-egui/src/shortcuts/tests_clear_label.rs @@ -112,6 +112,15 @@ fn compare_clears_only_the_active_photo_and_auto_advance_moves_on() { assert_eq!(app.session.active(), Some(PhotoId(2))); } +#[test] +fn a_label_given_to_clear_color_label_is_ignored_by_the_toast_too() { + let mut app = app().unwrap(); + app.run("photo.clearLabel", json!({"label": "red"})).unwrap(); + assert_eq!(labels(&app)[1], None, "the photo's label is cleared, whatever label was passed"); + let toast = app.ui.toast.as_ref().expect("a toast"); + assert_eq!((toast.0.as_str(), toast.2), ("Color label cleared", None), "not \"Red Label\""); +} + fn find<'a>(nodes: &'a [MenuNode], id: &str) -> Option<&'a MenuNode> { nodes.iter().find_map(|n| match n { MenuNode::Item { id: i, .. } if i == id => Some(n),