mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-25 00:22:43 -05:00
fix(floating-ai-search): prevent sending empty messages and handle loading state in input
This commit is contained in:
@@ -79,6 +79,7 @@ function SearchAIInput(props: ComponentProps<"form"> & { isMobile?: boolean }) {
|
||||
|
||||
const onStart = (e?: SyntheticEvent) => {
|
||||
e?.preventDefault();
|
||||
if (!input.trim() || isLoading) return;
|
||||
void sendMessage({ text: input });
|
||||
setInput("");
|
||||
};
|
||||
@@ -121,6 +122,10 @@ function SearchAIInput(props: ComponentProps<"form"> & { isMobile?: boolean }) {
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (!event.shiftKey && event.key === "Enter") {
|
||||
if (!input.trim() || isLoading) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
onStart(event);
|
||||
}
|
||||
}}
|
||||
@@ -149,7 +154,7 @@ function SearchAIInput(props: ComponentProps<"form"> & { isMobile?: boolean }) {
|
||||
className: "mt-2 rounded-full transition-all",
|
||||
}),
|
||||
)}
|
||||
disabled={input.length === 0}
|
||||
disabled={!input.trim() || isLoading}
|
||||
>
|
||||
<Send className="size-4" />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user