CE-WP-0008: fix capture field values and viewport scroll retry

- Wire fieldValues state in FormsApp so controlled inputs persist typed data
- Add runScrollToHighlightJob with rAF retries when utils/highlights not ready
- Re-trigger scroll when highlights update after PDF load
- Tests: scroll-job unit test, forms-field-values integration tests
- Workplan CE-WP-0008 marked done
This commit is contained in:
tegwick 2026-06-08 01:07:52 +02:00
parent fc6b91ccb0
commit 305a20d1d1
7 changed files with 384 additions and 17 deletions

View file

@ -64,9 +64,14 @@ export function FormsApp() {
[schema],
);
const [fieldValues, setFieldValues] = useState<Record<string, string>>({});
const [showAddFieldForm, setShowAddFieldForm] = useState(false);
const [editingFieldId, setEditingFieldId] = useState<string | null>(null);
const handleFieldValueChange = useCallback((fieldId: string, value: string) => {
setFieldValues((prev) => ({ ...prev, [fieldId]: value }));
}, []);
const nextFieldId = useCallback((fields: readonly FormFieldSchema[]): string => {
let max = 0;
for (const f of fields) {
@ -119,6 +124,8 @@ export function FormsApp() {
<ViewerShell />
<FormPane
schema={schema}
fieldValues={fieldValues}
onFieldValueChange={handleFieldValueChange}
showAddFieldForm={showAddFieldForm}
editingFieldId={editingFieldId}
onRequestAddField={() => {
@ -156,6 +163,8 @@ function ScrollBridge() {
function FormPane({
schema,
fieldValues,
onFieldValueChange,
showAddFieldForm,
editingFieldId,
onRequestAddField,
@ -166,6 +175,8 @@ function FormPane({
onCancelFieldEdit,
}: {
schema: FormSchema;
fieldValues: Readonly<Record<string, string>>;
onFieldValueChange: (fieldId: string, value: string) => void;
showAddFieldForm: boolean;
editingFieldId: string | null;
onRequestAddField: () => void;
@ -253,6 +264,8 @@ function FormPane({
{document ? (
<FormRenderer
schema={schema}
values={fieldValues}
onValueChange={onFieldValueChange}
linkCounts={linkCounts}
linkHints={linkHints}
showAddFieldForm={showAddFieldForm}