Skip to content

Commit ea13160

Browse files
committed
feat(textarea): overflow-y-auto
1 parent d4f4a69 commit ea13160

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/sender.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ export function Sender({
122122
const [isSending, setIsSending] = useState(false);
123123

124124
useEffect(() => {
125+
onMessageChange?.(message);
125126
if (textareaRef.current) {
126127
textareaRef.current.style.height = "auto";
127128
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
128129
}
129-
onMessageChange?.(message);
130130
}, [message, onMessageChange]);
131131

132132
const [controller, setController] = useState<AbortController | null>(null);
@@ -180,7 +180,9 @@ export function Sender({
180180
data-slot="sender"
181181
className={twMerge(
182182
clsx(
183-
"flex flex-col items-center border border-gray-200 dark:border-gray-700 rounded-2xl shadow-sm transition-all duration-300 hover:shadow-md focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500",
183+
"flex flex-col items-center border rounded-2xl",
184+
"border-gray-200 dark:border-gray-700 shadow-sm transition-all duration-300 hover:shadow-md",
185+
"focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500",
184186
className,
185187
),
186188
)}
@@ -192,7 +194,11 @@ export function Sender({
192194
onChange={handleChange}
193195
onKeyDown={handleKeyDown}
194196
placeholder={placeholder}
195-
className="w-full pt-4 px-4 border-0 rounded-2xl !resize-none focus:ring-0 focus:outline-none text-gray-700 placeholder-gray-400"
197+
className={clsx(
198+
"w-full pt-4 px-4 border-0 rounded-2xl !resize-none",
199+
"focus:ring-0 focus:outline-none text-gray-700 placeholder-gray-400",
200+
"overflow-y-auto max-h-32"
201+
)}
196202
rows={2}
197203
/>
198204
<div className="flex items-center w-full px-4 py-2 gap-4">
@@ -205,4 +211,4 @@ export function Sender({
205211
</div>
206212
</div>
207213
);
208-
}
214+
}

0 commit comments

Comments
 (0)