From 2e8a4313670296636d00fd422e39a58fa31d0ee6 Mon Sep 17 00:00:00 2001 From: Chandrapal Badshah <12944530+Chan9390@users.noreply.github.com> Date: Tue, 6 May 2025 15:30:34 +0530 Subject: [PATCH] Make textbox input better --- ui/app/(prowler)/lighthouse/chat.tsx | 50 ++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/ui/app/(prowler)/lighthouse/chat.tsx b/ui/app/(prowler)/lighthouse/chat.tsx index fbbc68e22a..8c6f839e46 100644 --- a/ui/app/(prowler)/lighthouse/chat.tsx +++ b/ui/app/(prowler)/lighthouse/chat.tsx @@ -1,6 +1,7 @@ "use client"; import { useChat } from "@ai-sdk/react"; +import { useRef } from "react"; import { MemoizedMarkdown } from "@/components/memoized-markdown"; @@ -50,6 +51,22 @@ export default function Chat() { }, ]; + const textareaRef = useRef(null); + + const handleAutoResizeInputChange = (e: React.ChangeEvent) => { + handleInputChange(e); + const textarea = textareaRef.current; + if (textarea) { + textarea.style.height = "auto"; + textarea.style.height = textarea.scrollHeight + "px"; + if (textarea.scrollHeight > textarea.clientHeight + 1) { + textarea.style.overflowY = "auto"; + } else { + textarea.style.overflowY = "hidden"; + } + } + }; + return (
{messages.length === 0 ? ( @@ -113,23 +130,30 @@ export default function Chat() { onSubmit={handleSubmit} className="mx-auto flex w-full gap-2 px-4 pb-4 md:max-w-3xl md:pb-6" > -
- +