mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-29 22:58:51 +01:00
✨ feat: Enhance form submission for touch screens
This commit is contained in:
parent
6e663b2480
commit
4eb0d3b073
1 changed files with 11 additions and 1 deletions
|
|
@ -126,6 +126,16 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => {
|
|||
});
|
||||
|
||||
const { submitMessage, submitPrompt } = useSubmitMessage();
|
||||
|
||||
const isTouchScreen = useMemo(() => window.matchMedia?.('(pointer: coarse)').matches, []);
|
||||
|
||||
const onSubmit = methods.handleSubmit((data: { text: string }) => {
|
||||
submitMessage(data);
|
||||
if (isTouchScreen) {
|
||||
textAreaRef.current?.blur();
|
||||
}
|
||||
});
|
||||
|
||||
const handleKeyUp = useHandleKeyUp({
|
||||
index,
|
||||
textAreaRef,
|
||||
|
|
@ -199,7 +209,7 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => {
|
|||
|
||||
return (
|
||||
<form
|
||||
onSubmit={methods.handleSubmit(submitMessage)}
|
||||
onSubmit={onSubmit}
|
||||
className={cn(
|
||||
'mx-auto flex flex-row gap-3 sm:px-2',
|
||||
maximizeChatSpace ? 'w-full max-w-full' : 'md:max-w-3xl xl:max-w-4xl',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue