DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Integration: #1505 leaving parent pages for a page fits its spread before centring the page
aiongg376cf3325a5f
diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rsindex f36269479..7d89a24a8 100644--- a/crates/ui-egui/src/canvas/tests.rs+++ b/crates/ui-egui/src/canvas/tests.rs@@ -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));+}diff --git a/crates/ui-egui/src/canvas/view.rs b/crates/ui-egui/src/canvas/view.rsindex b679923d2..2ba0876a1 100644--- a/crates/ui-egui/src/canvas/view.rs+++ b/crates/ui-egui/src/canvas/view.rs@@ -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);