diff --git a/components/ActionItem.tsx b/components/ActionItem.tsx index c675bb7..a0c74b8 100644 --- a/components/ActionItem.tsx +++ b/components/ActionItem.tsx @@ -1,5 +1,6 @@ +import { useEffect, useRef } from 'react'; import styles from '../styles/typea.module.css'; -import SelectNames from '../components/SelectNames' +import SelectNames from '../components/SelectNames'; const formatDate = (dateString: any) => { if (!dateString) return ""; @@ -18,67 +19,87 @@ const parseDate = (dateString: any) => { return `${year}-${month.toString().padStart(2, '0')}-${day.padStart(2, '0')}`; }; -const ActionItem = ({ item, itemIndex, handleUpdate, onRemove, agendaIndex, type }: any) => ( +const ActionItem = ({ item, itemIndex, handleUpdate, onRemove, agendaIndex, type }: any) => { + const actionRef = useRef(null); + + // Function to adjust height of the textarea + const adjustTextareaHeight = (textarea: HTMLTextAreaElement | null) => { + if (textarea) { + textarea.style.height = 'auto'; // Reset height + textarea.style.height = `${textarea.scrollHeight}px`; // Set to scrollHeight + } + }; + + // Auto-resize when content changes + useEffect(() => { + adjustTextareaHeight(actionRef.current); + }, [item.text]); + + return (
-
- - handleUpdate('text', e.target.value)} - autoComplete="off" - /> -
-
-
-
- - handleUpdate('assignee', selectedNames)} - initialValue={item.assignee} - /> -
-
- - handleUpdate('dueDate', formatDate(e.target.value))} - /> -
-
- - -
-
-
- -
-
-
- ); +
+ +