Skip to content

Commit

Permalink
fix bug: crash occurs when chat submit by clicking button on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
glowingjade committed Oct 24, 2024
1 parent 4572828 commit 88cedeb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/components/chat-view/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ const Chat = forwardRef<ChatRef, ChatProps>((props, ref) => {
<QueryProgress state={queryProgress} />
</div>
<ChatUserInput
key={inputMessage.id}
key={inputMessage.id} // this is needed to clear the editor when the user submits a new message
ref={(ref) => registerChatUserInputRef(inputMessage.id, ref)}
message={inputMessage.content}
onChange={(content) => {
Expand All @@ -554,7 +554,6 @@ const Chat = forwardRef<ChatRef, ChatProps>((props, ref) => {
[...chatMessages, { ...inputMessage, content }],
useVaultSearch,
)
chatUserInputRefs.current.get(inputMessage.id)?.clear()
setInputMessage(getNewInputMessage(app))
handleScrollToBottom()
}}
Expand Down
4 changes: 0 additions & 4 deletions src/components/chat-view/chat-input/ChatUserInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import { VaultSearchButton } from './VaultSearchButton'

export type ChatUserInputRef = {
focus: () => void
clear: () => void
}

export type ChatUserInputProps = {
Expand Down Expand Up @@ -98,9 +97,6 @@ const ChatUserInput = forwardRef<ChatUserInputRef, ChatUserInputProps>(
focus: () => {
contentEditableRef.current?.focus()
},
clear: () => {
updaterRef.current?.clear()
},
}))

const initialConfig: InitialConfigType = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -18,11 +17,6 @@ export default function UpdaterPlugin({
update: (content: SerializedEditorState) => {
editor.setEditorState(editor.parseEditorState(content))
},
clear: () => {
editor.update(() => {
$getRoot().clear()
})
},
}))

return null
Expand Down

0 comments on commit 88cedeb

Please sign in to comment.