@@ -19,7 +19,11 @@ function hasActiveMentionQuery(input: string): boolean {
1919export function Input ( { isDisabled = false , onSubmit } : Props ) {
2020 const { exit } = useApp ( ) ;
2121 const [ input , setInput ] = useState ( '' ) ;
22- const [ resetKey , setResetKey ] = useState ( 0 ) ;
22+ const [ inputKey , setInputKey ] = useState ( 0 ) ;
23+
24+ const remountTextInput = useCallback ( ( ) => {
25+ setInputKey ( ( key ) => key + 1 ) ;
26+ } , [ setInputKey ] ) ;
2327
2428 const handleSubmitText = useCallback (
2529 async ( input : string ) => {
@@ -36,9 +40,9 @@ export function Input({ isDisabled = false, onSubmit }: Props) {
3640
3741 onSubmit ( trimmedInput ) ;
3842 setInput ( '' ) ;
39- setResetKey ( ( key ) => key + 1 ) ;
43+ remountTextInput ( ) ;
4044 } ,
41- [ onSubmit ] ,
45+ [ onSubmit , remountTextInput ] ,
4246 ) ;
4347
4448 const handleSubmitCommand = useCallback (
@@ -49,21 +53,24 @@ export function Input({ isDisabled = false, onSubmit }: Props) {
4953
5054 onSubmit ( input ) ;
5155 setInput ( '' ) ;
52- setResetKey ( ( key ) => key + 1 ) ;
56+ remountTextInput ( ) ;
5357 } ,
54- [ onSubmit ] ,
58+ [ onSubmit , remountTextInput ] ,
5559 ) ;
5660
57- const handleSelectFileSuggestion = useCallback ( ( nextInput : string ) => {
58- setInput ( nextInput ) ;
59- setResetKey ( ( key ) => key + 1 ) ;
60- } , [ ] ) ;
61+ const handleSelectFileSuggestion = useCallback (
62+ ( nextInput : string ) => {
63+ setInput ( nextInput ) ;
64+ remountTextInput ( ) ;
65+ } ,
66+ [ remountTextInput ] ,
67+ ) ;
6168
6269 useInput ( ( _input , key ) => {
6370 if ( key . ctrl && _input === 'c' ) {
6471 if ( input ) {
6572 setInput ( '' ) ;
66- setResetKey ( ( key ) => key + 1 ) ;
73+ remountTextInput ( ) ;
6774 } else {
6875 exit ( ) ;
6976 }
@@ -81,7 +88,7 @@ export function Input({ isDisabled = false, onSubmit }: Props) {
8188 < TextInput
8289 defaultValue = { input }
8390 isDisabled = { isDisabled }
84- key = { resetKey }
91+ key = { inputKey }
8592 onChange = { setInput }
8693 // eslint-disable-next-line @typescript-eslint/no-misused-promises
8794 onSubmit = { handleSubmitText }
0 commit comments