From e6bc9b003c8ef2aa8a4b2bda6d866e94fa1627e1 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 23 Nov 2026 15:28:34 +0700 Subject: [PATCH] Libraries: a colour row's hex value is read with the row; the tests drag a group by its title row and keep their drag source row in place, so the rows stay where they were measured --- crates/ui-egui/src/panels/libraries.rs | 3 ++- crates/ui-egui/src/panels/libraries/tests.rs | 26 +++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/ui-egui/src/panels/libraries.rs b/crates/ui-egui/src/panels/libraries.rs index 794d5e6d53..feb326d682 100644 --- a/crates/ui-egui/src/panels/libraries.rs +++ b/crates/ui-egui/src/panels/libraries.rs @@ -640,7 +640,8 @@ impl<'a> View<'a> { } (_, Some(Look::Color(color))) => { let hex = color.to_hex(); - let row = if hex.eq_ignore_ascii_case(name) { row } else { row.trailing(hex) }; + // Named, so a screen reader reads the value with the row, as it is seen beside the name. + let row = if hex.eq_ignore_ascii_case(name) { row } else { row.trailing_named(hex.clone(), hex) }; row.thumb(ThumbSize::Small, move |cx, rect| Look::Color(color).paint(cx, rect)) } (_, Some(look)) => { diff --git a/crates/ui-egui/src/panels/libraries/tests.rs b/crates/ui-egui/src/panels/libraries/tests.rs index c0c01fc5ba..b95874de4d 100644 --- a/crates/ui-egui/src/panels/libraries/tests.rs +++ b/crates/ui-egui/src/panels/libraries/tests.rs @@ -26,17 +26,15 @@ fn app() -> VectorcraftApp { app } -/// The panel under a one-row list whose row drags what [`CARRIED`] holds, through the drag -/// session a real source starts. +/// The panel under a one-row list whose row drags what [`CARRIED`] holds when the drag starts, through the drag +/// session a real source starts. The row is always there, so the panel's rows stay where a test measured them. fn with_source(app: &mut VectorcraftApp, ui: &mut Ui) { - if let Some(drag) = CARRIED.with(|carried| carried.borrow().clone()) { - let rows = [SOURCE.to_string()]; - let _ = List::::new("Source") - .select(SelectMode::None) - .natural_height(true) - .drag_payload(move |_: &ListDrag| Some(drag.clone())) - .show_items(ui, &keyed(&rows, String::clone), &mut |key, _| ListRow::new(key.clone())); - } + let rows = [SOURCE.to_string()]; + let _ = List::::new("Source") + .select(SelectMode::None) + .natural_height(true) + .drag_payload(|_: &ListDrag| CARRIED.with(|carried| carried.borrow().clone())) + .show_items(ui, &keyed(&rows, String::clone), &mut |key, _| ListRow::new(key.clone())); show(app, ui); } @@ -180,7 +178,9 @@ fn item_onto_a_group_header_goes_into_that_group() { fn group_header_onto_a_groups_top_half_moves_the_group() { let mut panel = ordered(); let to = top(&panel, "Warm"); - panel.drag_to("Cool", to, Modifiers::NONE); + // The drag starts on Cool's title row (its heading), not the middle of the section, which lies in its body. + let from = panel.rect_role("Cool", craft::ui::contract::Role::HEADING).center(); + panel.drag_between(from, to, Modifiers::NONE); panel.frame(); assert_eq!(group_names(&mut panel.app()).iter().map(|(g, _)| g.as_str()).collect::>(), ["Cool", "Warm"]); } @@ -289,10 +289,12 @@ fn the_list_view_shows_hex_values_and_takes_drops_by_row() { } let mut panel = Harness::new(app, show); panel.frame(); + // A list row's text after its name is read with the row, as its description. + let beside = |panel: &Harness, name: &str, hex: &str| panel.description(name).is_some_and(|d| d.contains(hex)); assert!(!panel.shows("#0044aa"), "chips by default"); panel.app().ui.libraries_list_view = true; panel.frame(); - assert!(panel.shows("#0044aa") && panel.shows("#ffcc00"), "a colour's hex value beside its name"); + assert!(beside(&panel, "Ocean Blue", "#0044aa") && beside(&panel, "Sun Yellow", "#ffcc00"), "a colour's hex value beside its name"); // Sun Yellow onto Ocean Blue's top half: first. let to = top(&panel, "Ocean Blue"); panel.drag_to("Sun Yellow", to, Modifiers::NONE);