diff --git a/frontend/src/components/Alert.tsx b/frontend/src/components/Alert.tsx index 8eb6e2d2d8..9b177b02df 100644 --- a/frontend/src/components/Alert.tsx +++ b/frontend/src/components/Alert.tsx @@ -1,3 +1,4 @@ + import { cn } from '@/lib/utils'; import React from 'react'; @@ -89,7 +90,8 @@ export const Alert: React.FC = ({
{icons[variant]}
-

{children}

+ {/* Correction : Changement de

vers

pour autoriser les composants block-level comme Skeleton */} +
{children}
diff --git a/frontend/src/components/AutoResizeTextarea.tsx b/frontend/src/components/AutoResizeTextarea.tsx index e585a5201d..c4b96383f9 100644 --- a/frontend/src/components/AutoResizeTextarea.tsx +++ b/frontend/src/components/AutoResizeTextarea.tsx @@ -1,6 +1,6 @@ + +import React, { forwardRef, useEffect, useRef, useState, useImperativeHandle } from 'react'; import { cn } from '@/lib/utils'; -import { useEffect, useRef, useState } from 'react'; - import { Textarea } from '@/components/ui/textarea'; interface Props extends Omit, 'onPaste'> { @@ -16,7 +16,7 @@ interface Props extends Omit, 'onPaste'> { ) => void; } -const AutoResizeTextarea = ({ +const AutoResizeTextarea = forwardRef(({ maxHeight, onPaste, onEnter, @@ -26,10 +26,13 @@ const AutoResizeTextarea = ({ onCompositionStart, onCompositionEnd, ...props -}: Props) => { +}, ref) => { const textareaRef = useRef(null); const [isComposing, setIsComposing] = useState(false); + // Synchronise la ref locale (utilisée pour les calculs de hauteur) avec la ref externe + useImperativeHandle(ref, () => textareaRef.current!); + useEffect(() => { const textarea = textareaRef.current; if (!textarea || !onPaste) return; @@ -44,18 +47,18 @@ const AutoResizeTextarea = ({ useEffect(() => { const textarea = textareaRef.current; if (!textarea || !maxHeight) return; + + // Réinitialisation temporaire pour calculer le scrollHeight réel textarea.style.height = '40px'; const newHeight = Math.min(textarea.scrollHeight, maxHeight); textarea.style.height = `${newHeight}px`; }, [props.value, maxHeight]); const handleKeyDown = (event: React.KeyboardEvent) => { - // Call the parent's onKeyDown first (this is Input's handler) if (onKeyDown) { onKeyDown(event); } - // Only handle our Enter logic if the event wasn't already handled if ( !event.defaultPrevented && event.key === 'Enter' && @@ -88,7 +91,7 @@ const AutoResizeTextarea = ({ return (