From 88cedeb5c5b2c92b7446ac36dd6549212efb54c4 Mon Sep 17 00:00:00 2001 From: Heesu Suh Date: Thu, 24 Oct 2024 15:11:14 +0900 Subject: [PATCH] fix bug: crash occurs when chat submit by clicking button on mobile --- src/components/chat-view/Chat.tsx | 3 +-- src/components/chat-view/chat-input/ChatUserInput.tsx | 4 ---- .../chat-input/plugins/updater/UpdaterPlugin.tsx | 8 +------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/chat-view/Chat.tsx b/src/components/chat-view/Chat.tsx index 55a0aa8..c6cee8b 100644 --- a/src/components/chat-view/Chat.tsx +++ b/src/components/chat-view/Chat.tsx @@ -539,7 +539,7 @@ const Chat = forwardRef((props, ref) => { registerChatUserInputRef(inputMessage.id, ref)} message={inputMessage.content} onChange={(content) => { @@ -554,7 +554,6 @@ const Chat = forwardRef((props, ref) => { [...chatMessages, { ...inputMessage, content }], useVaultSearch, ) - chatUserInputRefs.current.get(inputMessage.id)?.clear() setInputMessage(getNewInputMessage(app)) handleScrollToBottom() }} diff --git a/src/components/chat-view/chat-input/ChatUserInput.tsx b/src/components/chat-view/chat-input/ChatUserInput.tsx index b0427d3..b1e9aa4 100644 --- a/src/components/chat-view/chat-input/ChatUserInput.tsx +++ b/src/components/chat-view/chat-input/ChatUserInput.tsx @@ -49,7 +49,6 @@ import { VaultSearchButton } from './VaultSearchButton' export type ChatUserInputRef = { focus: () => void - clear: () => void } export type ChatUserInputProps = { @@ -98,9 +97,6 @@ const ChatUserInput = forwardRef( focus: () => { contentEditableRef.current?.focus() }, - clear: () => { - updaterRef.current?.clear() - }, })) const initialConfig: InitialConfigType = { diff --git a/src/components/chat-view/chat-input/plugins/updater/UpdaterPlugin.tsx b/src/components/chat-view/chat-input/plugins/updater/UpdaterPlugin.tsx index 145354c..f767d0f 100644 --- a/src/components/chat-view/chat-input/plugins/updater/UpdaterPlugin.tsx +++ b/src/components/chat-view/chat-input/plugins/updater/UpdaterPlugin.tsx @@ -1,10 +1,9 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext' -import { $getRoot, SerializedEditorState } from 'lexical' +import { SerializedEditorState } from 'lexical' import { Ref, useImperativeHandle } from 'react' export type UpdaterPluginRef = { update: (content: SerializedEditorState) => void - clear: () => void } export default function UpdaterPlugin({ @@ -18,11 +17,6 @@ export default function UpdaterPlugin({ update: (content: SerializedEditorState) => { editor.setEditorState(editor.parseEditorState(content)) }, - clear: () => { - editor.update(() => { - $getRoot().clear() - }) - }, })) return null