mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-03 07:01:09 -06:00
Integration: #1505 leaving parent pages for a page fits its spread before centring the page
This commit is contained in:
@@ -2869,3 +2869,17 @@ fn table_cells_show_their_hidden_characters() {
|
||||
let last = marks.last().unwrap();
|
||||
assert_eq!((last.0, last.1), (designcraft_geom::Point::new(frag.rect.x1 + 1.0, frag.rect.y1), "¶"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leaving_parent_editing_for_the_left_page_of_a_spread_keeps_that_page_selected() {
|
||||
let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"pages": 4, "facingPages": true})).unwrap();
|
||||
let mut h = harness(app);
|
||||
h.state_mut().run("layout.parents.edit", json!({"on": true, "parent": "A-Parent"})).unwrap();
|
||||
h.run_steps(2);
|
||||
let b = page_box(h.state()).unwrap();
|
||||
// Page 2 is the left page of the second spread.
|
||||
page_box_go(h.state_mut(), &b, 1);
|
||||
h.run_steps(3);
|
||||
assert_eq!(current_page(h.state()), Some(1));
|
||||
}
|
||||
|
||||
@@ -188,9 +188,11 @@ pub fn page_box_go(app: &mut DesignApp, b: &PageBox, i: usize) {
|
||||
if i < b.pages {
|
||||
if app.session.active().is_some_and(|st| st.editing_parents) {
|
||||
let _ = app.run("layout.parents.edit", serde_json::json!({"on": false}));
|
||||
// The canvas refits to the page's spread once it is centred.
|
||||
if let Some(v) = app.view_mut() {
|
||||
v.fitted = false;
|
||||
// Fit the page's spread first, then centre the page: a later refit would centre the
|
||||
// spread, and the page box would then show its other page.
|
||||
let spread = app.session.active().and_then(|st| st.doc.page_loc(i)).map(|(si, _)| SpreadRef::Doc(si));
|
||||
if let Some(r) = spread {
|
||||
show_spread(app, r);
|
||||
}
|
||||
}
|
||||
go_to_page(app, i);
|
||||
|
||||
Reference in New Issue
Block a user