Layout › Page Setup: the group launcher opens the Page Setup dialog (#471) (#563)

The launcher ran ui.dialog, which needs a dialog name, but group
launchers run their command with no parameters, so nothing opened. It
now runs layout.pageSetup, which asks the UI for the Page Setup dialog,
as the Font and Paragraph launchers run their dialog commands.

The test opens the dialog through layout.pageSetup and checks that no
ribbon group uses ui.dialog as its launcher.

generated with Claude Code

Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
alexanderalber
2026-10-11 22:15:27 -04:00
committed by GitHub
co-authored by Brandon Thomas
parent e9da654903
commit 0db810d0e8
+16 -1
View File
@@ -994,7 +994,7 @@ fn design(app: &mut WordApp, ui: &mut Ui) {
}
fn layout(app: &mut WordApp, ui: &mut Ui) {
group(ui, "Page Setup", Some("ui.dialog"), app, |ui, app| {
group(ui, "Page Setup", Some("layout.pageSetup"), app, |ui, app| {
// Text Direction works on what the caret is in: table cells, a text box, else the section.
let dir = wordcraft_engine::cmd::page::text_direction_at(&app.session);
menu_button(ui, app, "textDirection", Some("Text\nDirection"), "Text Direction", true, |ui, app| {
@@ -2293,6 +2293,21 @@ mod tests {
assert!(!contextual_tabs(&s).contains(&"Shape Format"));
}
#[test]
fn page_setup_launcher_opens_the_dialog() {
// A group launcher runs its command with no parameters (#471).
let mut app = crate::WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
app.run("layout.pageSetup", json!({})).unwrap();
assert!(matches!(app.dialog, Some(crate::dialogs::Dialog::PageSetup { .. })));
// `ui.dialog` needs a dialog name, so it can't be a launcher.
let launchers: Vec<&str> = include_str!("ribbon.rs")
.split("group(ui, \"")
.filter_map(|g| g.split_once('"')?.1.strip_prefix(", Some(\"")?.split('"').next())
.collect();
assert!(launchers.contains(&"layout.pageSetup"), "{launchers:?}");
assert!(!launchers.contains(&"ui.dialog"), "{launchers:?}");
}
#[test]
fn smart_art_picker_inserts_and_design_tab_follows_the_selection() {
let mut app = crate::WordApp::new(Session::new(wordcraft_doc::Document::new()), Default::default());