= ({indexQuestion, initialTextQu
const handleTextareaQuestionChange = (event: React.ChangeEvent
) => {
setTextQuestion(event.target.value);
+
+ if (textareaQuestionRef.current) {
+ textareaQuestionRef.current.style.height = 'auto';
+ textareaQuestionRef.current.style.height = `${textareaQuestionRef.current.scrollHeight}px`;
+ }
}
const handleSaveQuestion = () => {
@@ -59,6 +64,8 @@ const QuestionItem: React.FC = ({indexQuestion, initialTextQu
useEffect(() => {
if (isEditingQuestion && textareaQuestionRef.current) {
textareaQuestionRef.current.focus();
+ textareaQuestionRef.current.style.height = 'auto';
+ textareaQuestionRef.current.style.height = `${textareaQuestionRef.current.scrollHeight}px`;
}
}, [isEditingQuestion]);
@@ -109,6 +116,7 @@ const QuestionItem: React.FC = ({indexQuestion, initialTextQu
onKeyDown={handleQuestionKeyDown}
onBlur={handleQuestionBlur}
placeholder={initialTextQuestion}
+ rows={1}
/>
) : (