Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(pdf): keep a stay whole across a page edge

Mauriceeb817dea6570
diff --git a/client/src/components/PDF/TripPDF.test.ts b/client/src/components/PDF/TripPDF.test.ts
index 02b487a67..e790275ec 100644
--- a/client/src/components/PDF/TripPDF.test.ts
+++ b/client/src/components/PDF/TripPDF.test.ts
@@ -1004,4 +1004,14 @@ describe('page breaks between days (#1292)', () => {
expect(() => toggle()!.click()).not.toThrow()
})
+
+ // Verified against a real print engine: without this rule Chromium tore a stay
+ // across the page edge, the check-in time on one sheet and the hotel name on
+ // the next. Place and note cards already carried it.
+ it('FE-PDF-BREAK-007: a stay may not be split by a page edge', async () => {
+ await downloadTripPDF(twoDays)
+ const html = getIframe()!.srcdoc
+ const rule = html.slice(html.indexOf('.day-accommodation {'))
+ expect(rule.slice(0, rule.indexOf('}'))).toContain('break-inside: avoid')
+ })
})
diff --git a/client/src/components/PDF/TripPDF.tsx b/client/src/components/PDF/TripPDF.tsx
index e1e019f66..174b20dc5 100644
--- a/client/src/components/PDF/TripPDF.tsx
+++ b/client/src/components/PDF/TripPDF.tsx
@@ -565,6 +565,10 @@ export async function downloadTripPDF({ trip, days, places, assignments = {}, ca
flex: 1 1 45%; min-width: 200px; margin: 4px 0; padding: 10px;
border: 2px solid #e2e8f0; border-radius: 12px;
display: flex; flex-direction: column;
+ /* Place and note cards have said this all along; without it a stay is torn
+ in half by a page edge, its check-in time on one sheet and the hotel name
+ on the next. Rare while every day started a page, common once they flow. */
+ break-inside: avoid; page-break-inside: avoid;
}
.day-accommodation-title {
font-size: 16px; font-weight: 600; text-align: center;