diff --git a/frontend/src/components/SommelierCard.tsx b/frontend/src/components/SommelierCard.tsx index 7b60612..a0f3bfa 100644 --- a/frontend/src/components/SommelierCard.tsx +++ b/frontend/src/components/SommelierCard.tsx @@ -19,7 +19,8 @@ interface SommelierCardProps { } // Format feedback: split into paragraphs -function formatFeedback(text: string): React.ReactNode[] { +// Uses stable keys based on content hash to prevent React DOM reconciliation errors +function formatFeedback(text: string): React.ReactNode { // Split into sentences - but only at sentence boundaries // A sentence ends with .!? followed by space and uppercase letter // This avoids breaking "Next.js", "e.g.", "i.e.", etc. @@ -39,9 +40,16 @@ function formatFeedback(text: string): React.ReactNode[] { } }); - return paragraphs.map((p, idx) => ( -
0 ? 'mt-3' : ''}>{p}
- )); + // Wrap in a single container to avoid DOM reconciliation issues when toggling expansion + // This prevents the "insertBefore" error caused by React trying to reconcile + // multiple paragraph elements when the parent's className changes + return ( +{p}
+ ))} +