Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ› fix: Fix the issue of the input box losing focus after sending a message on the desktop version #830

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/features/ChatInput/useChatInput.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TextAreaRef } from 'antd/es/input/TextArea';
import { useCallback, useRef, useState } from 'react';

import { useIsMobile } from '@/hooks/useIsMobile';
import { useChatStore } from '@/store/chat';
import { useGlobalStore } from '@/store/global';
import { useSessionStore } from '@/store/session';
Expand All @@ -23,12 +24,15 @@ export const useChatInput = () => {
s.updateInputMessage,
s.stopGenerateMessage,
]);
const mobile = useIsMobile();

const handleSend = useCallback(() => {
setExpand(false);
ref?.current?.blur();
if (mobile) {
ref?.current?.blur();
}
onSend();
}, [onSend]);
}, [onSend, mobile]);

return {
canUpload,
Expand Down
Loading