Merge pull request #9338 from dotCooCoo/fix/variables-reclick-selects

Variables: a click on the highlighted variable selects its bound object again
This commit is contained in:
BFlat authored and GitHub committed 2026-11-27 05:15:12 +07:00
commit dc0be374eb
1 file changed
+26
+26
View File
@@ -546,6 +546,8 @@ fn variable_table(ui: &mut Ui, vars: &[VarRow], sort: VariableSort, states: &Row
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } if !opening_menu => {
acts.extend(keys.into_iter().next().map(Act::Click));
}
// A click on the highlighted row changes no selection, and still selects what it drives.
CollectionEvent::Picked { key, .. } if !opening_menu => acts.push(Act::Click(key)),
CollectionEvent::Activate(name) if !states.locked => acts.push(Act::Options(name)),
_ => {}
}
@@ -1240,6 +1242,30 @@ mod tests {
assert_eq!(sets["datasets"][0]["name"], "Data Set 2");
}
/// A click on the highlighted row selects what it drives again, as a click on any other row
/// does: after the art is deselected on the canvas, the row stays highlighted, and a second
/// click on it selects the bound object.
#[test]
fn a_click_on_the_highlighted_row_selects_its_bound_object_again() {
use crate::tests::panel_harness::Panel;
let mut app = app_with_data();
let bound = app.session.doc().unwrap().doc.variables.objects_of("Name")[0];
app.session.execute("select.set", &json!({"ids": []})).unwrap();
let mut p = Panel::new(app, show);
let selected = |p: &Panel| p.app().session.doc().unwrap().selection.objects.clone();
let highlighted = |p: &Panel| highlighted_row(p.app().session.doc().unwrap());
p.click("Name");
assert_eq!(highlighted(&p).as_deref(), Some("Name"));
assert_eq!(selected(&p), vec![bound], "the first click selects the bound object");
p.app().session.execute("select.set", &json!({"ids": []})).unwrap();
assert!(selected(&p).is_empty());
// A second later, so the two clicks are not a double click.
p.advance(1.0);
p.click("Name");
assert_eq!(highlighted(&p).as_deref(), Some("Name"));
assert_eq!(selected(&p), vec![bound], "a click on the highlighted row selects the bound object again");
}
/// The rows as the panel built them on every frame before [`cached_rows`] kept them: the
/// identity checks compare against it.
fn old_rows(st: &DocState, xml_id: bool) -> Rows {