Merge PR #632: Header & Footer dialog opens on the saved header and footer

crates/ui-egui/tests/interaction.rs: keep both new tests
This commit is contained in:
aiongg
2026-10-22 02:34:42 +00:00
2 changed files with 23 additions and 1 deletions
+5 -1
View File
@@ -393,7 +393,11 @@ impl Dialog {
Text { key: "header", label: "Header (&L left, &C center, &R right; &P page, &N pages, &D date, &A sheet):" },
Text { key: "footer", label: "Footer:" },
],
json!({"header": "", "footer": "&CPage &P of &N"}),
{
let sheet = app.session.active().and_then(|d| d.wb.active());
let (header, footer) = sheet.map(|s| (s.print.header.clone(), s.print.footer.clone())).unwrap_or_default();
json!({"header": header, "footer": footer})
},
),
"pageSetup" => {
// Opens on the active sheet's saved margins, so OK without edits rewrites them unchanged.
+18
View File
@@ -911,3 +911,21 @@ fn undo_after_backspace_restores_the_cleared_cell() {
assert_eq!(value(&h, "A1"), Value::Number(3200.0));
assert_eq!(value(&h, "C5"), Value::Number(11750.0));
}
#[test]
fn header_footer_dialog_opens_on_the_saved_header_and_footer() {
// #523: the dialog started from a fixed empty header and `&CPage &P of &N`, so OK replaced the sheet's text.
let mut s = blank();
s.execute("pageLayout.headerFooter", json!({"header": "&LLeft", "footer": "&CConfidential"})).unwrap();
let mut h = harness(s);
h.state_mut().open_dialog("headerFooter", json!({}));
h.run_steps(2);
let d = h.state_mut().dialog.as_mut().unwrap();
assert_eq!(d.values["header"], json!("&LLeft"));
assert_eq!(d.values["footer"], json!("&CConfidential"));
d.values.insert("header".into(), json!("&CNew"));
let vals = json!(d.values.clone());
h.state_mut().run("pageLayout.headerFooter", vals).unwrap();
let pr = &h.state().session.active().unwrap().wb.active().unwrap().print;
assert_eq!((pr.header.as_str(), pr.footer.as_str()), ("&CNew", "&CConfidential"));
}