@@ -13,7 +13,6 @@ import {
13
13
PopoverContent ,
14
14
PopoverTrigger ,
15
15
} from "@/components/ui/popover" ;
16
- import { useDebounce } from "@/hooks/use-debounce" ;
17
16
import { cn } from "@/lib/utils" ;
18
17
import type React from "react" ;
19
18
import { useEffect , useRef , useState } from "react" ;
@@ -43,25 +42,13 @@ export const LinearCombobox = ({
43
42
const [ searchValue , setSearchValue ] = useState ( "" ) ;
44
43
const onValueChangeRef = useRef ( onValueChange ) ;
45
44
const isSearching = searchValue . length > 0 ;
46
- const { debouncedValue } = useDebounce ( searchValue ) ;
45
+
47
46
useEffect ( ( ) => {
48
47
if ( selectedOption && onValueChangeRef . current ) {
49
48
onValueChangeRef . current ( selectedOption ) ;
50
49
}
51
50
} , [ selectedOption ] ) ;
52
51
53
- useEffect ( ( ) => {
54
- if ( Number . parseInt ( debouncedValue ) < options . length ) {
55
- const possibleOption = options [ Number . parseInt ( debouncedValue ) ] ;
56
- if ( possibleOption ) {
57
- setSelectedOption ( possibleOption ) ;
58
- setOpenPopover ( false ) ;
59
- setSearchValue ( "" ) ;
60
- return ;
61
- }
62
- }
63
- } , [ debouncedValue , options ] ) ;
64
-
65
52
return (
66
53
< Popover open = { openPopover } onOpenChange = { setOpenPopover } modal >
67
54
< PopoverTrigger asChild >
@@ -98,7 +85,18 @@ export const LinearCombobox = ({
98
85
< Command className = "rounded-lg relative" >
99
86
< CommandInput
100
87
value = { searchValue }
101
- onValueChange = { setSearchValue }
88
+ onValueChange = { ( value ) => {
89
+ if ( Number . parseInt ( value ) < options . length ) {
90
+ const possibleOption = options [ Number . parseInt ( value ) ] ;
91
+ if ( possibleOption ) {
92
+ setSelectedOption ( possibleOption ) ;
93
+ setOpenPopover ( false ) ;
94
+ setSearchValue ( "" ) ;
95
+ return ;
96
+ }
97
+ }
98
+ setSearchValue ( value ) ;
99
+ } }
102
100
className = "text-[0.8125rem] leading-normal"
103
101
placeholder = "Type Option no"
104
102
/>
0 commit comments