--- id: CE-WP-0008 type: workplan title: "Capture content editing & viewport scroll reliability" domain: citation_evidence repo: citation-evidence repo_id: a677c189-b4e2-4f2a-9e48-faa482c277e6 topic_slug: citation_evidence_mvp topic_id: 96fa8e80-9f74-40f2-84cd-644e9747b9ec status: done owner: Bernd created: 2026-06-08 updated: 2026-06-08 depends_on_workplan: CE-WP-0007 planning_order: 8 planning_priority: high spec_refs: - wiki/ProductRequirementsDocument.md - workplans/CE-WP-0007-capture-view-polish.md state_hub_workstream_id: "864e4661-f6d8-482e-8a44-bebc69e6b9df" --- # CE-WP-0008 — Capture Content Editing & Viewport Scroll Follow-on fixes from manual Capture-mode demo use after CE-WP-0007. ## User requirements (locked) 1. **Field values persist while typing** — text, textarea, and date inputs must keep user-entered content; re-renders must not reset controlled inputs. 2. **Date fields hold their value** — picking a date must not snap back to empty or a stale display value on blur or parent re-render. 3. **Viewport scroll reaches off-page evidence** — selecting evidence whose passage is not on page 1 must scroll the PDF viewer to that passage (not leave the viewport at the document top). CE-WP-0007 T01 regressed or was incomplete when `PdfHighlighter` utils or highlight DOM were not ready on the first scroll request. ## Dependency order ``` T01 (field value state) ── T02 (viewport scroll retry) └─ T03 (integration tests) ``` --- ## T01 — Wire form field value state in FormsApp ```task id: CE-WP-0008-T01 priority: critical status: done state_hub_task_id: "b48bd06d-3ba0-4589-b6d3-5ff4a8474fb5" ``` **Problem:** `FormRenderer` renders controlled inputs (`value={… ?? ""}`) but `FormsApp` never passes `values` / `onValueChange`. Every React re-render resets typed content; date inputs snap back immediately. **Fix:** - Hold `fieldValues: Record` in `FormsApp`. - Pass `values` and `onValueChange` through `FormPane` → `FormRenderer`. - Preserve values when field label/type is edited (stable field `id`). **Acceptance:** type in Summary, switch focus to another field, return — text remains. Set a date — value persists after blur. --- ## T02 — Retry scroll until viewer utils and highlight are ready ```task id: CE-WP-0008-T02 priority: critical status: done depends_on: [T01] state_hub_task_id: "68b73689-27ff-45c4-bd9f-2e0817e97b1f" ``` **Problem:** `PdfSpikeViewer`'s scroll `useEffect` bails when `utilsRef` or the target highlight is missing, and never retries because effect deps do not change. Evidence on page 2+ appears to leave the viewport at the document top. **Fix:** - Extract `runScrollToHighlightJob` with rAF retries (same pattern as `centerHighlightInViewer`). - Re-run pending scroll when `highlights` updates (annotations rendered after PDF load). - Keep `lastScrollKeyRef` guard so successful scrolls are not duplicated. **Acceptance:** click strip evidence tied to a page-2+ passage — viewer receives `scrollToAnnotationId` and scroll completes once utils are available. --- ## T03 — Integration tests ```task id: CE-WP-0008-T03 priority: high status: done depends_on: [T01, T02] state_hub_task_id: "fdf259a1-1789-42ca-a95f-d98ae6422509" ``` Happy-dom tests: - Type text and date in capture fields; refocus; values persist. - Unit test for scroll job retry when utils arrive late. **Acceptance:** `npm run test` green. --- ## Acceptance for the workplan After CE-WP-0008: 1. Capture form fields retain typed values across re-renders and focus changes. 2. Date inputs keep the selected date after blur. 3. Evidence selection scrolls to off-page passages instead of staying at the top.