Preferences open over the Home page (#313)
The Home page returned from the frame before the Preferences window was drawn, so the gear, Ctrl+, and Home's Preferences / Keyboard Shortcuts links only set the flag and the dialog appeared after leaving Home. Draw the Preferences window on Home too. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e6e0a7ebb5
commit
250d8a2c04
2 files changed
+26
No files matched your search
@@ -605,4 +605,28 @@ mod tests {
|
||||
assert_eq!(app.session.doc.name, "Sample Plate");
|
||||
assert!(!app.session.is_dirty());
|
||||
}
|
||||
|
||||
/// The gear, Ctrl+, and Home's own links open Preferences over Home, not after leaving it.
|
||||
#[test]
|
||||
fn preferences_and_shortcuts_open_over_home() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
let rev = h.app.session.revision;
|
||||
h.app.home.show(rev);
|
||||
h.frames(2);
|
||||
assert!(h.app.home.open);
|
||||
let gear = crate::scenario::handle_at("titlebar:preferences").unwrap();
|
||||
h.call("ui.click", serde_json::json!({"x": gear.x, "y": gear.y}));
|
||||
assert!(h.app.prefs_window.open && h.app.home.open);
|
||||
let shown = |h: &crate::scenario::Harness| {
|
||||
h.ctx.memory(|m| m.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::new("sc_prefs"))))
|
||||
};
|
||||
assert!(shown(&h), "the Preferences window must be drawn on Home");
|
||||
h.call("ui.prefs", serde_json::json!({"button": "cancel"}));
|
||||
assert!(!shown(&h));
|
||||
|
||||
// Home › Keyboard Shortcuts opens the same window at its page.
|
||||
h.app.keymap.open = true;
|
||||
h.frames(2);
|
||||
assert!(shown(&h) && h.app.prefs_window.section == crate::prefs::PAGE_SHORTCUTS && h.app.home.open);
|
||||
}
|
||||
}
|
||||
@@ -978,6 +978,8 @@ impl SolveApp {
|
||||
if self.home.open {
|
||||
home::show(self, ui);
|
||||
if self.home.open {
|
||||
// Preferences and Keyboard Shortcuts open from Home too (its links, the gear, Ctrl+,).
|
||||
prefs::show(self, ui.ctx());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user