From 6ce8c5fb5594e5c3d6bf93f14ee5b16ac0aed772 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 13:40:48 -0800 Subject: [PATCH 1/2] Variables: a click on the highlighted variable selects its bound object again The Variables table ran the row click only when the table's selection changed. A click on the row that is already highlighted leaves that selection as it was, so after the art was deselected on the canvas, a second click on the same variable selected nothing. The table now also runs the row click on the collection's Picked event, which reports a click that leaves the selection unchanged. --- crates/ui-egui/src/panels/variables.rs | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/ui-egui/src/panels/variables.rs b/crates/ui-egui/src/panels/variables.rs index 3ff0fd0191..257d986eb2 100644 --- a/crates/ui-egui/src/panels/variables.rs +++ b/crates/ui-egui/src/panels/variables.rs @@ -522,6 +522,8 @@ fn variable_table(ui: &mut Ui, vars: &[VarRow], sort: VariableSort, states: &Row } } CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => 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, .. } => acts.push(Act::Click(key)), CollectionEvent::Activate(name) if !states.locked => acts.push(Act::Options(name)), _ => {} } @@ -956,6 +958,33 @@ 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 egui::accesskit::Role; + let mut app = app_with_data(); + let bound = app.session.doc().unwrap().doc.variables.objects_of("Name")[0]; + let mut d = Driver::new(); + let row = |d: &mut Driver, app: &mut VectorcraftApp| { + let nodes = d.nodes(app); + nodes.iter().find(|(_, n)| n.role() != Role::ColumnHeader && n.label() == Some("Name")).expect("the Name row").1.clone() + }; + let selected = |app: &VectorcraftApp| app.session.doc().unwrap().selection.objects.clone(); + app.session.execute("select.set", &json!({"ids": []})).unwrap(); + let cell = row(&mut d, &mut app); + d.click(&mut app, &cell); + assert_eq!(highlighted_row(app.session.doc().unwrap()).as_deref(), Some("Name")); + assert_eq!(selected(&app), vec![bound], "the first click selects the bound object"); + app.session.execute("select.set", &json!({"ids": []})).unwrap(); + assert!(selected(&app).is_empty()); + let cell = row(&mut d, &mut app); + d.click(&mut app, &cell); + assert_eq!(highlighted_row(app.session.doc().unwrap()).as_deref(), Some("Name")); + assert_eq!(selected(&app), 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 { From a42bdf83998e310708bd1a943fbd78215ed7cb4b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 18:49:09 -0800 Subject: [PATCH 2/2] Variables: the highlighted-row test drives the panel through the panel harness The test of a second click on the highlighted variable clicks the row through tests::panel_harness::Panel instead of the file's hand-written frame loop. --- crates/ui-egui/src/panels/variables.rs | 31 ++++++++++++-------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/crates/ui-egui/src/panels/variables.rs b/crates/ui-egui/src/panels/variables.rs index 257d986eb2..901db60fc4 100644 --- a/crates/ui-egui/src/panels/variables.rs +++ b/crates/ui-egui/src/panels/variables.rs @@ -963,26 +963,23 @@ mod tests { /// click on it selects the bound object. #[test] fn a_click_on_the_highlighted_row_selects_its_bound_object_again() { - use egui::accesskit::Role; + use crate::tests::panel_harness::Panel; let mut app = app_with_data(); let bound = app.session.doc().unwrap().doc.variables.objects_of("Name")[0]; - let mut d = Driver::new(); - let row = |d: &mut Driver, app: &mut VectorcraftApp| { - let nodes = d.nodes(app); - nodes.iter().find(|(_, n)| n.role() != Role::ColumnHeader && n.label() == Some("Name")).expect("the Name row").1.clone() - }; - let selected = |app: &VectorcraftApp| app.session.doc().unwrap().selection.objects.clone(); app.session.execute("select.set", &json!({"ids": []})).unwrap(); - let cell = row(&mut d, &mut app); - d.click(&mut app, &cell); - assert_eq!(highlighted_row(app.session.doc().unwrap()).as_deref(), Some("Name")); - assert_eq!(selected(&app), vec![bound], "the first click selects the bound object"); - app.session.execute("select.set", &json!({"ids": []})).unwrap(); - assert!(selected(&app).is_empty()); - let cell = row(&mut d, &mut app); - d.click(&mut app, &cell); - assert_eq!(highlighted_row(app.session.doc().unwrap()).as_deref(), Some("Name")); - assert_eq!(selected(&app), vec![bound], "a click on the highlighted row selects the bound object again"); + 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