LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
LR-BEHAV-ACCESS: a month's disclosure triangle names its year
Nathaniel Ledford7d8b2d7e0e78
diff --git a/crates/ui-egui/src/panels/left/dates.rs b/crates/ui-egui/src/panels/left/dates.rsindex 8b91379f8..09f942914 100644--- a/crates/ui-egui/src/panels/left/dates.rs+++ b/crates/ui-egui/src/panels/left/dates.rs@@ -26,7 +26,8 @@ fn date_row(app: &mut LightcraftApp, ui: &mut egui::Ui, key: &str, label: &str,let sel = app.session.filter.date.as_deref() == Some(key);let resp = Row::new(&format!("date:{key}"), Icon::Clock, label).count(Some(count)).selected(sel).indent(indent).show(app, ui);if key.len() < 10 {- tree_toggle(ui, &resp, indent, open_id, &mut open, format!("dateToggle:{key}"), label);+ // (the name carries the year, so two Marches in different years differ in a screen reader's list of triangles)+ tree_toggle(ui, &resp, indent, open_id, &mut open, format!("dateToggle:{key}"), &crate::i18n::date_group_label(key, false));}if resp.clicked() {let v = if sel { serde_json::Value::Null } else { json!(key) };diff --git a/crates/ui-egui/tests/it/sidebar_names.rs b/crates/ui-egui/tests/it/sidebar_names.rsindex f4a241973..e063a42b7 100644--- a/crates/ui-egui/tests/it/sidebar_names.rs+++ b/crates/ui-egui/tests/it/sidebar_names.rs@@ -2,7 +2,10 @@//! opens or closes, so a list of them is not "Expand, Expand, Expand".use egui::accesskit::Role;use egui::vec2;-use egui_kittest::{Harness, kittest::NodeT};+use egui_kittest::{+ Harness,+ kittest::{NodeT, Queryable},+};use lightcraft_ui_egui::{LightcraftApp, Services,state::{RightPanel, ViewMode},@@ -38,6 +41,37 @@ fn a_disclosure_triangle_names_its_row() {assert!(!names.iter().any(|n| n == "Expand" || n == "Collapse"), "no triangle is just a verb: {names:?}");}+/// The same month in two years gets two different triangle names ("Expand March 2025", not two+/// "Expand March").+#[test]+fn a_month_triangle_names_its_year() {+ let mut session = lightcraft_engine::Session::with_demo();+ let ids: Vec<_> = session.catalog.photos().map(|p| p.id).take(2).collect();+ for (id, captured) in ids.into_iter().zip(["2025-03-05T10:00:00", "2026-03-05T10:00:00"]) {+ session.catalog.apply(lightcraft_catalog::Op::SetCaptured { id, captured: Some(captured.into()) }).expect("the capture time is set");+ }+ let mut app = LightcraftApp::new(session, Services { png: None, ..Default::default() });+ app.ui.left_panel = true;+ app.ui.view = ViewMode::PhotoGrid;+ app.ui.right = RightPanel::None;+ let mut h = Harness::builder().with_size(vec2(1500.0, 950.0)).build_ui_state(+ |ui, app: &mut LightcraftApp| {+ app.logic(&ui.ctx().clone());+ app.ui(ui);+ },+ app,+ );+ h.run_steps(10);+ for year in ["Expand 2025", "Expand 2026"] {+ h.get_by_label(year).click();+ h.run_steps(5);+ }+ let names = button_names(&h);+ assert!(names.iter().any(|n| n == "Expand March 2025"), "{names:?}");+ assert!(names.iter().any(|n| n == "Expand March 2026"), "{names:?}");+ assert!(!names.iter().any(|n| n == "Expand March"), "no month triangle lacks its year: {names:?}");+}+/// The Keyword List (right panel ▸ Keywords) is its own code path: its triangles name the keyword/// they open, by its own name and not its whole path ("Expand Italy", not "Expand Trips|Italy").#[test]