File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export function useCurrentInput() {
7
7
const [ navigation , setNavigation ] = useState ( 0 ) ;
8
8
9
9
const navigate = useCallback (
10
- ( direction : 'up' | 'down' | 'bottom' ) => {
10
+ ( direction : 'up' | 'down' ) => {
11
11
setNavigation ( n => {
12
12
let newValue : number ;
13
13
switch ( direction ) {
@@ -17,14 +17,11 @@ export function useCurrentInput() {
17
17
case 'down' :
18
18
newValue = Math . max ( n - 1 , 0 ) ;
19
19
break ;
20
- case 'bottom' :
21
- newValue = 0 ;
22
- break ;
23
20
}
24
21
if ( newValue > 0 ) {
25
22
setCurrentInput ( history [ history . length - newValue ] ) ;
26
23
}
27
- if ( newValue === 0 && ( direction === 'up' || direction === 'down' ) ) {
24
+ if ( newValue === 0 ) {
28
25
setCurrentInput ( '' ) ;
29
26
}
30
27
return newValue ;
@@ -33,13 +30,10 @@ export function useCurrentInput() {
33
30
[ history ] ,
34
31
) ;
35
32
36
- const onInput = useCallback (
37
- ( e : string | FormEvent < HTMLTextAreaElement > ) => {
38
- navigate ( 'bottom' ) ;
39
- setCurrentInput ( typeof e === 'string' ? e : e . currentTarget . value ) ;
40
- } ,
41
- [ navigate ] ,
42
- ) ;
33
+ const onInput = useCallback ( ( e : string | FormEvent < HTMLTextAreaElement > ) => {
34
+ setNavigation ( 0 ) ;
35
+ setCurrentInput ( typeof e === 'string' ? e : e . currentTarget . value ) ;
36
+ } , [ ] ) ;
43
37
44
38
const upArrow = useCallback ( ( ) => {
45
39
if ( currentInput . trim ( ) . length !== 0 && navigation === 0 ) {
You can’t perform that action at this time.
0 commit comments