Merge pull request #9437 from dotCooCoo/fix/ui-graph-design-footer-ok

Honor the OK button in Graph Column and Graph Marker
This commit is contained in:
BFlat authored and GitHub committed 2026-11-27 00:47:22 +07:00
commit 4fada43e8c
1 file changed
+48 -4
+48 -4
View File
@@ -519,13 +519,14 @@ impl GraphDesignDialog {
}
true
});
if let Some(options) = shown.accepted {
self.column = options;
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
}
}
@@ -836,6 +837,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 +881,48 @@ mod tests {
assert!(!dialogs.with(|host| host.is_open::<GraphDesignDialog>()));
}
#[test]
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!({}));
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);
if dismiss {
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();
}
h.run_steps(4);
let app = h.state_mut();
assert!(!app.dialogs().unwrap().with(|host| host.is_open::<GraphDesignDialog>()));
let expected = if dismiss { Value::Null } else { json!("New Design") };
assert_eq!(app.session.execute(command, &json!({})).unwrap()["design"], expected);
}
}
#[test]
fn marker_lists_the_designs_and_applies_the_one_picked() {
let (mut app, ctx) = app_with_design();