From 372d864d3e5b9f5ad265cd862cbfddb9eafe55b0 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 7 Nov 2026 15:22:16 +0100 Subject: [PATCH] Brush Settings: name the Spacing percentage field for accessibility (#5224) After merging main, the newer egui_kittest accessibility check failed the PR's spacing tests: the percentage field next to the Spacing checkbox had no accessible name. Name it "Spacing" and query the checkbox by role in the tests, since the field now shares the label. Co-Authored-By: augrclk Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/brush_panel/tests.rs | 6 +++--- crates/ui-egui/src/panels/brush_sections.rs | 5 ++++- crates/ui-egui/src/panels/brush_sections/tests.rs | 7 ++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/panels/brush_panel/tests.rs b/crates/ui-egui/src/panels/brush_panel/tests.rs index ca2ab47d587..a11fe034c31 100644 --- a/crates/ui-egui/src/panels/brush_panel/tests.rs +++ b/crates/ui-egui/src/panels/brush_panel/tests.rs @@ -1886,7 +1886,7 @@ fn spacing_row_edits_route_only_the_changed_fields_through_the_brush_command() { h.run_steps(2); let journal = h.state().session.journal.len(); let spacing = h.state().session.tools.brush.spacing; - let checkbox = h.query_all_by_label("Spacing").min_by(|a, b| a.rect().top().total_cmp(&b.rect().top())).unwrap(); + let checkbox = h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Spacing"); checkbox.click(); h.run_steps(2); assert!(h.state().session.tools.brush.spacing_enabled); @@ -1900,7 +1900,7 @@ fn spacing_row_edits_route_only_the_changed_fields_through_the_brush_command() { assert_eq!(h.state().session.tools.brush.spacing, 0.44); assert_eq!(last_journal(h.state()).unwrap().0, "tools.setBrush"); assert_eq!(last_journal(h.state()).unwrap().1["brush"], json!({"spacing": 0.44_f32})); - let checkbox = h.query_all_by_label("Spacing").min_by(|a, b| a.rect().top().total_cmp(&b.rect().top())).unwrap(); + let checkbox = h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Spacing"); checkbox.click(); h.run_steps(2); assert_eq!(last_journal(h.state()).unwrap().1["brush"], json!({"spacingEnabled": false})); @@ -1911,7 +1911,7 @@ fn spacing_row_edits_route_only_the_changed_fields_through_the_brush_command() { h.run_steps(2); assert_eq!(h.state().session.tools.brush.spacing, 0.44); assert_eq!(h.state().session.journal.len(), journal + 3, "disabled input adds no command"); - let checkbox = h.query_all_by_label("Spacing").min_by(|a, b| a.rect().top().total_cmp(&b.rect().top())).unwrap(); + let checkbox = h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Spacing"); checkbox.click(); h.run_steps(2); assert_eq!(h.state().session.tools.brush.spacing, 0.44); diff --git a/crates/ui-egui/src/panels/brush_sections.rs b/crates/ui-egui/src/panels/brush_sections.rs index c74a75b452d..976766abe94 100644 --- a/crates/ui-egui/src/panels/brush_sections.rs +++ b/crates/ui-egui/src/panels/brush_sections.rs @@ -61,7 +61,10 @@ fn spacing_row(ui: &mut egui::Ui, b: &mut BrushSettings) { ui.horizontal(|ui| { widgets::checkbox(ui, &mut b.spacing_enabled, tl!("Spacing")).on_hover_text(tl!("Off: the speed of the pointer sets the spacing")); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - changed = ui.add_enabled_ui(b.spacing_enabled, |ui| widgets::value_field(ui, &mut percent, 1.0..=1000.0, "%", 74.0)).inner.changed(); + changed = ui + .add_enabled_ui(b.spacing_enabled, |ui| widgets::value_field(ui, &mut percent, 1.0..=1000.0, "%", 74.0).accessible_name(tl!("Spacing"))) + .inner + .changed(); }); }); changed |= ui.add_enabled_ui(b.spacing_enabled, |ui| widgets::slider(ui, &mut percent, 1.0..=1000.0, None)).inner.changed(); diff --git a/crates/ui-egui/src/panels/brush_sections/tests.rs b/crates/ui-egui/src/panels/brush_sections/tests.rs index 823c4779925..66cb16d43f6 100644 --- a/crates/ui-egui/src/panels/brush_sections/tests.rs +++ b/crates/ui-egui/src/panels/brush_sections/tests.rs @@ -344,8 +344,9 @@ fn spacing_row_has_one_label_and_a_shared_header_in_every_theme() { let mut h = section_harness(0, b.clone()); crate::PhotocraftApp::setup_context(&h.ctx, kind); h.run_steps(3); - assert_eq!(h.query_all_by_label("Spacing").count(), 1, "{kind:?}: the checkbox is the single label"); - let checkbox = h.get_by_label("Spacing").rect(); + assert_eq!(h.query_all_by_role_and_label(Role::Label, "Spacing").count(), 0, "{kind:?}: the checkbox is the single label"); + assert_eq!(h.query_all_by_role_and_label(Role::CheckBox, "Spacing").count(), 1); + let checkbox = h.get_by_role_and_label(Role::CheckBox, "Spacing").rect(); let field = h.query_all_by_role(Role::SpinButton).find(|node| node.accesskit_node().numeric_value() == Some(43.0)).unwrap(); assert!((checkbox.center().y - field.rect().center().y).abs() < 2.0, "{kind:?}: checkbox and percentage share a row"); assert_eq!(field.accesskit_node().is_disabled(), !enabled); @@ -368,7 +369,7 @@ fn spacing_row_retains_disabled_values_and_percentage_editing_limits() { h.run_steps(2); drag(&mut h, from, to); assert_eq!(h.state(), &before, "Off ignores both field input and a track drag"); - let checkbox = h.query_all_by_label("Spacing").min_by(|a, b| a.rect().top().total_cmp(&b.rect().top())).unwrap(); + let checkbox = h.get_by_role_and_label(Role::CheckBox, "Spacing"); checkbox.click(); h.run_steps(2); assert!(h.state().spacing_enabled);