diff --git a/crates/ui-egui/src/dialogs/data.rs b/crates/ui-egui/src/dialogs/data.rs index e3eabda79..e57a90c4e 100644 --- a/crates/ui-egui/src/dialogs/data.rs +++ b/crates/ui-egui/src/dialogs/data.rs @@ -218,8 +218,11 @@ pub(super) fn sort(app: &mut SheetApp, ui: &mut egui::Ui, d: &mut Dialog, confir if columns.is_empty() { ui.add(egui::TextEdit::singleline(&mut col).desired_width(50.0)).labelled_by(label.id); } else { + // The closed box shows the same "B: Revenue" label as the list, not the bare letter (#3446). + let shown = + columns.iter().find(|(letter, _)| letter.eq_ignore_ascii_case(&col)).map_or_else(|| col.clone(), |(_, label)| label.clone()); craft_ui::ComboBox::from_id_salt(("sort_col", i)) - .selected_text(col.clone()) + .selected_text(shown) .show_ui(ui, |ui| { for (letter, label) in &columns { ui.selectable_value(&mut col, letter.clone(), label.as_str()); diff --git a/crates/ui-egui/tests/it/sort_dialog_columns.rs b/crates/ui-egui/tests/it/sort_dialog_columns.rs index b6cbb54f6..098f9c3e6 100644 --- a/crates/ui-egui/tests/it/sort_dialog_columns.rs +++ b/crates/ui-egui/tests/it/sort_dialog_columns.rs @@ -34,6 +34,18 @@ fn sort_dialog_seeds_the_active_column() { assert_eq!(col(&h), "B", "Sort by starts on the column the cursor is in, not A"); } +/// #3446: the closed "Sort by" box shows the column's name next to its letter, +/// as the open list does ("B: Revenue", not just "B"). +#[test] +fn closed_column_box_shows_the_column_name() { + use egui::accesskit::Role; + let mut h = harness(sales()); + h.state_mut().open_dialog("sort", json!({})); + h.run_steps(2); + let shown: Vec = h.get_all_by_role(Role::ComboBox).filter_map(|n| n.value()).collect(); + assert!(shown.iter().any(|v| v == "B: Revenue"), "the Sort by box shows the column name: {shown:?}"); +} + #[test] fn add_level_picks_a_column_no_level_uses_yet() { let mut h = harness(sales());