Improve UX

This commit is contained in:
2025-09-17 21:54:05 +03:00
Unverified
parent 39677f695f
commit ef4d09556e
3 changed files with 10 additions and 6 deletions
@@ -8,7 +8,7 @@ interface ChatInputWrapperProps {
export function ChatInputWrapper({ onSendMessage }: ChatInputWrapperProps) {
const [message, setMessage] = useState("");
const handleSubmit = async (e: React.FormEvent) => {
const handleSubmit = async (e: React.FormEvent | Event) => {
e.preventDefault();
if (message.trim()) {
onSendMessage(message);
@@ -27,7 +27,8 @@ export function ChatInputWrapper({ onSendMessage }: ChatInputWrapperProps) {
autoComplete="off"
text={message}
rows={1}
onTextChange={(value) => setMessage(value)} />
onTextChange={(value) => setMessage(value)}
onEnter={handleSubmit} />
<button type="submit" className="send-btn">
<span className="material-symbols filled">send</span>
</button>
@@ -3,8 +3,8 @@ import { useEffect, useRef, useCallback, useLayoutEffect } from "react";
interface RichTextAreaProps {
text: string;
onTextChange: (value: string) => void;
onEnter?: "newLine" | null | (() => void);
onCtrlEnter?: (() => void) | null;
onEnter?: "newLine" | null | ((e: React.KeyboardEvent<HTMLTextAreaElement>) => void);
onCtrlEnter?: ((e: React.KeyboardEvent<HTMLTextAreaElement>) => void) | null;
placeholder?: string;
id?: string;
className?: string;
@@ -155,7 +155,7 @@ export function RichTextArea({
if (isCtrlEnter) {
e.preventDefault();
if (typeof onCtrlEnter === "function") {
onCtrlEnter();
onCtrlEnter(e);
}
return;
}
@@ -171,7 +171,7 @@ export function RichTextArea({
}
if (typeof onEnter === "function") {
e.preventDefault();
onEnter();
onEnter(e);
return;
}
}