mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-08 03:22:59 +00:00
Merge pull request #3506 from ZIDAN44/fix/3446-sort-dialog-column-label
Sort: the closed Sort by box names the column, as its list does (#3446)
This commit is contained in:
2 files changed
+16
-1
No files matched your search
@@ -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());
|
||||
|
||||
@@ -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<String> = 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());
|
||||
|
||||
Reference in new issue
Block a user