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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
committed 2026-11-07 15:23:13 +01:00
1 parent fd4f9c9703
commit 372d864d3e
3 files changed
+11 -7

No files matched your search

@@ -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);
+4 -1
View File
@@ -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();
@@ -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);