Select by Artboards dialog: a plain click keeps artboards the search hides (#5548)

A plain click chose only the clicked row and dropped artboards chosen
but hidden by the search. It now replaces only the rows shown, as None
and Select All already do, so hidden rows keep their state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ruchirguitar
2026-11-05 00:16:17 +07:00
committed by bflatastic
co-authored by Claude Opus 5.5
parent 020275520c
commit 7f3d2b6406
2 changed files with 13 additions and 4 deletions
+6 -2
View File
@@ -57,7 +57,7 @@ pub(crate) fn shown(names: &[String], query: &str) -> Vec<usize> {
names.iter().enumerate().filter(|(_, n)| q.is_empty() || n.to_lowercase().contains(&q)).map(|(i, _)| i).collect()
}
/// A click on row `i` of the rows `shown`: alone it chooses only that artboard, with Cmd/Ctrl it
/// A click on row `i` of the rows `shown`: alone it chooses only that artboard of those shown, with Cmd/Ctrl it
/// toggles it, with Shift it adds the rows from the last one clicked (`anchor`) to it. Returns the
/// new anchor.
pub(crate) fn click(chosen: &mut Vec<usize>, anchor: Option<usize>, i: usize, shown: &[usize], shift: bool, command: bool) -> Option<usize> {
@@ -75,7 +75,11 @@ pub(crate) fn click(chosen: &mut Vec<usize>, anchor: Option<usize>, i: usize, sh
}
None => chosen.push(i),
},
_ => *chosen = vec![i],
// Of the rows shown, only this one; rows the search hides keep their state.
_ => {
chosen.retain(|j| !shown.contains(j));
chosen.push(i);
}
}
chosen.sort_unstable();
Some(i)
+7 -2
View File
@@ -45,7 +45,11 @@ fn clicks_choose_toggle_and_extend_rows() {
let a = click(&mut c, a, 3, &rows, false, false);
assert_eq!((c.clone(), a), (vec![3], Some(3)));
let a = click(&mut c, None, 5, &rows, true, false);
assert_eq!((c, a), (vec![5], Some(5)));
assert_eq!((c.clone(), a), (vec![5], Some(5)));
// Board 4, chosen but hidden by the search, stays chosen through a plain click.
c.push(4);
click(&mut c, a, 2, &rows, false, false);
assert_eq!(c, vec![2, 4]);
}
#[test]
@@ -92,7 +96,8 @@ fn double_clicking_a_row_fits_its_artboard_and_keeps_the_choice() {
// The search shows boards 0 and 2: row 2 is the second row, but board 2 is the one fitted.
let rows = [0, 2];
row_clicked(&mut d, 2, &rows, egui::Modifiers::NONE);
assert_eq!(d.fields["artboards"], json!([2]), "the first click chooses the row");
// Board 1, hidden by the search, stays chosen.
assert_eq!(d.fields["artboards"], json!([1, 2]), "the first click chooses the row among those shown");
// The dialog frame lends the dialog to its body while the app still shows it.
app.ui.dialog = Some(d.clone());
row_double_clicked(&mut app, &mut d, 2);