From c22f3fc753f48d17c09e1cccd0b694957905c77c Mon Sep 17 00:00:00 2001 From: cesnimda Date: Sat, 10 Oct 2026 21:55:01 +0200 Subject: [PATCH] fix(cv): wait for usable layout before preview pagination --- .../phase-5/p5-15/p5-15-04/mobile-preview/README.md | 10 ++++++++++ job-tracker-ui/src/cvPreview.ts | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/docs/redesign/phase-5/p5-15/p5-15-04/mobile-preview/README.md b/docs/redesign/phase-5/p5-15/p5-15-04/mobile-preview/README.md index e43aa26..2c52423 100644 --- a/docs/redesign/phase-5/p5-15/p5-15-04/mobile-preview/README.md +++ b/docs/redesign/phase-5/p5-15/p5-15-04/mobile-preview/README.md @@ -9,3 +9,13 @@ Two additional native Chromium regressions in `e2e/cv-pagination.spec.ts` reprod The injected one-shot script measures `.page` before its display:none ancestor becomes visible, constructs permanent zero-width column flow and announces a settled layout. Fonts/images readiness does not establish usable geometry. Correction must await actual layout without altering PDF, page dimensions, print spacing, fonts or existing fidelity tolerances. PRES-C06 is FAIL at this reproduction checkpoint; C09/C12 retain independently passing PDF evidence and incomplete acceptance. This record makes no repair/full-suite claim. Screen-reader, real-device and production font/photo qualifications remain incomplete. + +## Repair successor — GO for the bounded lifecycle repair + +`previewDocumentHtml` now waits for a nonzero `.page` width using a ResizeObserver only when initial layout is hidden. It disconnects immediately when usable geometry is available, then uses the unchanged physical measurement/print fragmentation path. Visible documents take the original path directly. No PDF, geometry, typography, margin, splitting rule, save or revision behaviour is changed. + +Fresh native results: all four pagination cases pass (two existing plus two new hidden-initial cases). The unchanged owned mobile Edit→Preview/API PDF case passes against a rebuilt frontend. Standard native exports pass **16/16,36preview=36PDF**; settings exports pass **8/8,24=24**, with unchanged0.5mm dimensions/2mm positions/0.5pt fonts/1/255 RGB/exact page count+membership tolerances. The associated seven readiness/settings browser cases pass, including independent-client conflicts and stale draft download/reload. Frontend498/498, TypeScript/lint/build and revision5/5 pass. + +Performance: the observer exists only for a hidden initial frame and is disconnected after its first usable layout. Hide/show, orientation and external scale changes in the regression produce no additional ready event/pagination work; no per-keystroke polling, extra preview remount or continuous reflow loop is introduced. Duration includes any time spent intentionally hidden, so it is not an isolated CPU timing benchmark. Production hardware throughput is not qualified by local Windows measurements. + +PRES-C06 can return FAIL→PARTIAL for this corrected lifecycle; full human/device/font/photo acceptance remains open. The original02 report stays historical NO-GO until its other P1 repair and successor matrix are reconciled. Production remains NO-GO. diff --git a/job-tracker-ui/src/cvPreview.ts b/job-tracker-ui/src/cvPreview.ts index 05d629d..aae921b 100644 --- a/job-tracker-ui/src/cvPreview.ts +++ b/job-tracker-ui/src/cvPreview.ts @@ -6,6 +6,13 @@ export function previewDocumentHtml(html: string, fallbackHeightPx: number, page const page=document.querySelector('.page');if(!page)return; await document.fonts.ready; await Promise.all(Array.from(document.images).map(image=>image.decode().catch(()=>{}))); + // Visible-page frames can start inside the compact editor's hidden pane. + if(!page.getBoundingClientRect().width)await new Promise(resolve=>{ + const observer=new ResizeObserver(()=>{ + if(page.getBoundingClientRect().width){observer.disconnect();resolve();} + }); + observer.observe(page); + }); const width=page.getBoundingClientRect().width; const height=parseFloat(getComputedStyle(page).minHeight)||${fallbackHeightPx}; const margin=parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--cv-page-margin'))*96/25.4;