@@ -45,7 +45,9 @@ const InputArea = ({
45
45
const [ filteredCommands , setFilteredCommands ] = useState ( CommandsList ) ;
46
46
const [ selectedCommandIndex , setSelectedCommandIndex ] = useState < number > ( 0 ) ;
47
47
48
+ // Keyboard
48
49
const isSendKeyEnter = useAtomValue ( store . isSendKeyEnterAtom ) ;
50
+ const [ isComposing , setIsComposing ] = useState < boolean > ( false ) ;
49
51
50
52
const enableSystemPrompt = useAtomValue ( store . enableSystemPrompt ) ;
51
53
@@ -188,7 +190,19 @@ const InputArea = ({
188
190
toast . success ( `${ t ( 'Copied share link:' ) } ${ conversationID } ` ) ;
189
191
} ;
190
192
193
+ const handleCompositionStart = ( ) => {
194
+ setIsComposing ( true ) ;
195
+ } ;
196
+
197
+ const handleCompositionEnd = ( ) => {
198
+ setIsComposing ( false ) ;
199
+ } ;
200
+
191
201
const handleOnKeyDown = ( e : any ) => {
202
+ if ( isComposing ) {
203
+ return ;
204
+ }
205
+
192
206
const isShiftKey = e . shiftKey ;
193
207
const isEnterKey = e . key === 'Enter' ;
194
208
const isEscapeKey = e . key === 'Escape' ;
@@ -201,9 +215,6 @@ const InputArea = ({
201
215
if ( showCommands && isEnterKey ) {
202
216
e . preventDefault ( ) ;
203
217
handleCommandClick ( `/${ filteredCommands [ selectedCommandIndex ] . name } ` ) ;
204
- } else if ( isSendOnEnter || isSendOnShiftEnter ) {
205
- e . preventDefault ( ) ;
206
- handleSend ( ) ;
207
218
} else if ( isEscapeKey ) {
208
219
setShowCommands ( false ) ;
209
220
} else if ( isUpArrow && showCommands ) {
@@ -213,6 +224,11 @@ const InputArea = ({
213
224
e . preventDefault ( ) ;
214
225
setSelectedCommandIndex ( ( prevIndex ) => ( prevIndex < filteredCommands . length - 1 ? prevIndex + 1 : prevIndex ) ) ;
215
226
}
227
+
228
+ if ( isSendOnEnter || isSendOnShiftEnter ) {
229
+ e . preventDefault ( ) ;
230
+ handleSend ( ) ;
231
+ }
216
232
} ;
217
233
218
234
const handleCommandClick = ( command : string ) => {
@@ -301,6 +317,8 @@ const InputArea = ({
301
317
value = { userInput }
302
318
onChange = { handleTextAreaChange }
303
319
onKeyDown = { handleOnKeyDown }
320
+ onCompositionStart = { handleCompositionStart }
321
+ onCompositionEnd = { handleCompositionEnd }
304
322
ref = { textAreaRef }
305
323
/>
306
324
< div className = 'absolute bottom-2 right-2 flex items-center justify-center' >
0 commit comments