diff --git a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/FieldPlacer.tsx b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/FieldPlacer.tsx index 0999448..7f59134 100644 --- a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/FieldPlacer.tsx +++ b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/FieldPlacer.tsx @@ -155,9 +155,10 @@ interface FieldPlacerProps { currentPage: number; children: React.ReactNode; readOnly?: boolean; + onFieldsChanged?: () => void; } -export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = false }: FieldPlacerProps) { +export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = false, onFieldsChanged }: FieldPlacerProps) { const [fields, setFields] = useState([]); const [isDraggingToken, setIsDraggingToken] = useState(null); const containerRef = useRef(null); @@ -294,8 +295,9 @@ export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = const next = [...fields, newField]; setFields(next); persistFields(docId, next); + onFieldsChanged?.(); }, - [fields, pageInfo, currentPage, docId, readOnly], + [fields, pageInfo, currentPage, docId, readOnly, onFieldsChanged], ); // --- Move / Resize pointer handlers (event delegation on DroppableZone) --- @@ -477,6 +479,7 @@ export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = }); setFields(next); persistFields(docId, next); + onFieldsChanged?.(); } else if (drag.type === 'resize') { const corner = drag.corner ?? 'se'; const startW = drag.startFieldW ?? 144; @@ -543,8 +546,9 @@ export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = }); setFields(next); persistFields(docId, next); + onFieldsChanged?.(); } - }, [docId]); + }, [docId, onFieldsChanged]); // Render placed fields for the current page // Uses pageInfo.width/height (not getBoundingClientRect) for consistent coordinate math @@ -653,6 +657,7 @@ export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = const next = fields.filter((f) => f.id !== field.id); setFields(next); persistFields(docId, next); + onFieldsChanged?.(); }} onPointerDown={(e) => { // Prevent dnd-kit sensors and move handler from capturing this pointer event