An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
prevented search submit when no input value
Anusha Yellaedc14f896266
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsxindex 1dda2b63..4f3ee0a5 100644--- a/components/chat-panel.tsx+++ b/components/chat-panel.tsx@@ -6,7 +6,6 @@ import type { AI, UIState } from '@/app/actions'import { useUIState, useActions } from 'ai/rsc'import { cn } from '@/lib/utils'import { UserMessage } from './user-message'-import { Input } from './ui/input'import { Button } from './ui/button'import { ArrowRight, Plus } from 'lucide-react'import { EmptyScreen } from './empty-screen'@@ -36,6 +35,9 @@ export function ChatPanel({ messages }: ChatPanelProps) {const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {e.preventDefault()+ // Do not submit if input is empty+ if (input.length === 0) return+// Clear messages if button is pressedif (isButtonPressed) {handleClear()