diff --git a/src/app/admin/_components/FormField.tsx b/src/app/admin/_components/FormField.tsx index cea629d..5c67cf8 100644 --- a/src/app/admin/_components/FormField.tsx +++ b/src/app/admin/_components/FormField.tsx @@ -1,3 +1,5 @@ +import { useRef, useEffect } from "react"; + interface InputFieldProps { label: string; value: string; @@ -42,15 +44,36 @@ export function TextareaField({ placeholder, rows = 3, }: TextareaFieldProps) { + const ref = useRef(null); + + useEffect(() => { + const el = ref.current; + if (!el) return; + el.style.height = "auto"; + el.style.height = el.scrollHeight + "px"; + }, [value]); + + useEffect(() => { + function onResize() { + const el = ref.current; + if (!el) return; + el.style.height = "auto"; + el.style.height = el.scrollHeight + "px"; + } + window.addEventListener("resize", onResize); + return () => window.removeEventListener("resize", onResize); + }, []); + return (