From 6e190e189aeccde32834bc774878fe1feaacaa0b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 08:07:25 -0800 Subject: [PATCH 1/3] Fix the Graph Column and Marker OK footer --- crates/ui-egui/src/dialogs/graph_design.rs | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/graph_design.rs b/crates/ui-egui/src/dialogs/graph_design.rs index 2bfdf7b913..f361b5f8c6 100644 --- a/crates/ui-egui/src/dialogs/graph_design.rs +++ b/crates/ui-egui/src/dialogs/graph_design.rs @@ -519,8 +519,7 @@ impl GraphDesignDialog { } true }); - if let Some(options) = shown.accepted { - self.column = options; + if shown.picked == Some(0) && !waiting { let answer = self.answer(); self.held.file(answer); return None; @@ -836,6 +835,7 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { #[cfg(test)] mod tests { + use egui_kittest::kittest::Queryable; use serde_json::{Value, json}; use super::GraphDesignDialog; @@ -879,6 +879,36 @@ mod tests { assert!(!dialogs.with(|host| host.is_open::())); } + #[test] + fn graph_design_footer_ok_applies_column_and_marker_designs() { + for (graph_type, command) in [("column", "graph.column"), ("line", "graph.marker")] { + let (mut app, ctx) = app_with_design(); + select_graph(&mut app, graph_type); + crate::menus::invoke(&mut app, command, json!({})); + set(&app, &ctx, "selected", json!("New Design")).unwrap(); + + let mut fonts = false; + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(900.0, 700.0)).build_ui_state( + move |ui, app: &mut VectorcraftApp| { + if !std::mem::replace(&mut fonts, true) { + crate::testing::install(ui.ctx()); + return; + } + app.dialogs().unwrap().with(|host| host.run(ui)); + super::pump(app, ui.ctx()); + }, + app, + ); + h.run_steps(4); + h.get_by_label("OK").click(); + h.run_steps(4); + + let app = h.state_mut(); + assert!(!app.dialogs().unwrap().with(|host| host.is_open::())); + assert_eq!(app.session.execute(command, &json!({})).unwrap()["design"], "New Design"); + } + } + #[test] fn marker_lists_the_designs_and_applies_the_one_picked() { let (mut app, ctx) = app_with_design(); From a67e60394404d830ebf65648b24c88cd19d2e4f4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 08:30:36 -0800 Subject: [PATCH 2/3] Cancel a Graph design when Escape shares the OK frame --- crates/ui-egui/src/dialogs/graph_design.rs | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/graph_design.rs b/crates/ui-egui/src/dialogs/graph_design.rs index f361b5f8c6..cf0c4dc6e1 100644 --- a/crates/ui-egui/src/dialogs/graph_design.rs +++ b/crates/ui-egui/src/dialogs/graph_design.rs @@ -519,12 +519,14 @@ impl GraphDesignDialog { } true }); + if shown.closed.is_some() { + return Some(DialogResult::Cancel); + } if shown.picked == Some(0) && !waiting { let answer = self.answer(); self.held.file(answer); - return None; } - shown.closed.map(|_| DialogResult::Cancel) + None } } @@ -880,8 +882,8 @@ mod tests { } #[test] - fn graph_design_footer_ok_applies_column_and_marker_designs() { - for (graph_type, command) in [("column", "graph.column"), ("line", "graph.marker")] { + fn graph_design_footer_ok_applies_column_and_marker_designs_unless_dismissed() { + for (graph_type, command, dismiss) in [("column", "graph.column", false), ("line", "graph.marker", false), ("column", "graph.column", true)] { let (mut app, ctx) = app_with_design(); select_graph(&mut app, graph_type); crate::menus::invoke(&mut app, command, json!({})); @@ -900,12 +902,26 @@ mod tests { app, ); h.run_steps(4); - h.get_by_label("OK").click(); + if dismiss { + let pos = h.get_by_label("OK").rect().center(); + let button = + |pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + h.hover_at(pos); + h.event(button(true)); + h.step(); + h.input_mut().events.extend([ + button(false), + egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }, + ]); + } else { + h.get_by_label("OK").click(); + } h.run_steps(4); let app = h.state_mut(); assert!(!app.dialogs().unwrap().with(|host| host.is_open::())); - assert_eq!(app.session.execute(command, &json!({})).unwrap()["design"], "New Design"); + let expected = if dismiss { Value::Null } else { json!("New Design") }; + assert_eq!(app.session.execute(command, &json!({})).unwrap()["design"], expected); } } From 25647e6e256d2037403fa7ea3f448175ccec24c3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 08:36:42 -0800 Subject: [PATCH 3/3] Exercise Graph design dismissal without a captured press --- crates/ui-egui/src/dialogs/graph_design.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/dialogs/graph_design.rs b/crates/ui-egui/src/dialogs/graph_design.rs index cf0c4dc6e1..348287e7bd 100644 --- a/crates/ui-egui/src/dialogs/graph_design.rs +++ b/crates/ui-egui/src/dialogs/graph_design.rs @@ -903,16 +903,14 @@ mod tests { ); h.run_steps(4); if dismiss { - let pos = h.get_by_label("OK").rect().center(); - let button = - |pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; - h.hover_at(pos); - h.event(button(true)); - h.step(); - h.input_mut().events.extend([ - button(false), - egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }, - ]); + h.get_by_label("OK").click_accesskit(); + h.input_mut().events.push(egui::Event::Key { + key: egui::Key::Escape, + physical_key: None, + pressed: true, + repeat: false, + modifiers: Default::default(), + }); } else { h.get_by_label("OK").click(); }