🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(chat-input): restore editor focus after file picker closes (#15394)
Innei0208c0adfe62
diff --git a/src/features/ChatInput/ActionBar/Plus/index.tsx b/src/features/ChatInput/ActionBar/Plus/index.tsxindex bac9660736b..a369dcfd972 100644--- a/src/features/ChatInput/ActionBar/Plus/index.tsx+++ b/src/features/ChatInput/ActionBar/Plus/index.tsx@@ -277,6 +277,7 @@ const PlusAction = memo(() => {const isMemoryEnabled = useMemoryEnabled(agentId);const [showTypoBar, setShowTypoBar] = useChatInputStore((s) => [s.showTypoBar, s.setShowTypoBar]);+ const editor = useChatInputStore((s) => s.editor);const { canUploadImage, canUploadVideo } = useVisualMediaUploadAbility(model, provider);const enableFC = useModelSupportToolUse(model, provider);const handleOpenKnowledge = useCallback(() => {@@ -415,6 +416,7 @@ const PlusAction = memo(() => {return false;}setDropdownOpen(false);+ editor?.focus();await upload([file]);return false;}}@@ -566,6 +568,7 @@ const PlusAction = memo(() => {activeSearchOption,canUploadImage,canUploadVideo,+ editor,enableFC,enableKnowledgeBase,handleOpenTools,diff --git a/src/features/ChatInput/ActionBar/Upload/index.tsx b/src/features/ChatInput/ActionBar/Upload/index.tsxindex d335daebf91..24d3b91c53a 100644--- a/src/features/ChatInput/ActionBar/Upload/index.tsx+++ b/src/features/ChatInput/ActionBar/Upload/index.tsx@@ -22,6 +22,7 @@ import { useUserStore } from '@/store/user';import { preferenceSelectors } from '@/store/user/selectors';import { useAgentId } from '../../hooks/useAgentId';+import { useChatInputStore } from '../../store';import Action from '../components/Action';import { type ActionDropdownMenuItems } from '../components/ActionDropdown';import CheckboxItem from '../components/CheckboxWithLoading';@@ -43,6 +44,7 @@ const FileUpload = memo(() => {);const upload = useFileStore((s) => s.uploadChatFiles);+ const editor = useChatInputStore((s) => s.editor);const agentId = useAgentId();const model = useAgentStore((s) => agentByIdSelectors.getAgentModelById(agentId)(s));@@ -83,6 +85,7 @@ const FileUpload = memo(() => {showUploadList={false}beforeUpload={async (file) => {setDropdownOpen(false);+ editor?.focus();await upload([file]);return false;@@ -123,6 +126,7 @@ const FileUpload = memo(() => {}setDropdownOpen(false);+ editor?.focus();await upload([file]);return false;@@ -160,6 +164,7 @@ const FileUpload = memo(() => {}setDropdownOpen(false);+ editor?.focus();await upload([file]);return false;diff --git a/src/features/EditorCanvas/editorAttachments.ts b/src/features/EditorCanvas/editorAttachments.tsindex c19013c1ef2..1cf996c744e 100644--- a/src/features/EditorCanvas/editorAttachments.ts+++ b/src/features/EditorCanvas/editorAttachments.ts@@ -46,6 +46,9 @@ export const insertFilesIntoEditor = (editor: IEditor | undefined, files: File[]lexicalEditor.dispatchCommand(INSERT_FILE_COMMAND, { file });}}+ // File picker / Upload dropdown steals focus; restore it so the cursor+ // remains visible and the user can keep typing.+ editor.focus?.();};export const pickAndInsertAttachments = (editor: IEditor | undefined, accept?: string): void => {