fix orphan prevention

- Include new headers at the start as part of the region's header rows
- Check if header rows are all rows
This commit is contained in:
PgBiel 2025-04-06 14:01:25 -03:00
parent fe08df8ee6
commit 0c6fae92f0
2 changed files with 7 additions and 1 deletions

View File

@ -1447,7 +1447,7 @@ impl<'a> GridLayouter<'a> {
.as_ref()
.and_then(Repeatable::as_repeated)
.is_none_or(|footer| footer.start != last_header_end)
&& self.lrows.last().is_some_and(|row| row.index() < last_header_end)
&& self.lrows.len() == self.current_header_rows
&& !in_last_with_offset(
self.regions,
// Since we're trying to find a region where to place all

View File

@ -373,6 +373,7 @@ impl<'a> GridLayouter<'a> {
}
if let HeadersToLayout::NewHeaders { headers, short_lived } = headers {
let placing_at_the_start = skipped_region || self.lrows.is_empty();
for header in headers {
let header_height =
self.layout_header_rows(header.unwrap(), engine, disambiguator)?;
@ -391,6 +392,11 @@ impl<'a> GridLayouter<'a> {
}
}
}
if placing_at_the_start {
// Track header rows at the start of the region.
self.current_header_rows = self.lrows.len();
}
}
Ok(())