7
7
useCombobox ,
8
8
useMultipleSelection
9
9
} from "downshift" ;
10
- import { useCallback , useMemo , useRef , useEffect } from "react" ;
10
+ import { useCallback , useMemo } from "react" ;
11
11
import { A11yStatusMessage , MultiSelector } from "../helpers/types" ;
12
12
13
13
export type UseDownshiftMultiSelectPropsReturnValue = UseMultipleSelectionReturnValue < string > &
@@ -37,12 +37,6 @@ export function useDownshiftMultiSelectProps(
37
37
options : Options ,
38
38
a11yStatusMessage : A11yStatusMessage
39
39
) : UseDownshiftMultiSelectPropsReturnValue {
40
- const isInitializing = useRef ( true ) ;
41
-
42
- useEffect ( ( ) => {
43
- isInitializing . current = false ;
44
- } , [ ] ) ;
45
-
46
40
const {
47
41
getSelectedItemProps,
48
42
getDropdownProps,
@@ -97,7 +91,6 @@ export function useDownshiftMultiSelectProps(
97
91
removeSelectedItem ,
98
92
setSelectedItems ,
99
93
a11yStatusMessage ,
100
- isInitializing ,
101
94
options
102
95
)
103
96
) ;
@@ -147,7 +140,6 @@ function useComboboxProps(
147
140
removeSelectedItem : ( item : string ) => void ,
148
141
setSelectedItems : ( item : string [ ] ) => void ,
149
142
a11yStatusMessage : A11yStatusMessage ,
150
- isInitializing : React . MutableRefObject < boolean > ,
151
143
options ?: Options
152
144
) : UseComboboxProps < string > {
153
145
return useMemo ( ( ) => {
@@ -156,13 +148,9 @@ function useComboboxProps(
156
148
selectedItem : null ,
157
149
inputId : options ?. inputId ,
158
150
labelId : options ?. labelId ,
159
- onInputValueChange ( { inputValue, type } ) {
151
+ onInputValueChange ( { inputValue } ) {
160
152
selector . options . setSearchTerm ( inputValue ! ) ;
161
- if (
162
- ! isInitializing . current &&
163
- type === useCombobox . stateChangeTypes . InputChange &&
164
- selector . onFilterInputChange
165
- ) {
153
+ if ( selector . onFilterInputChange ) {
166
154
selector . onFilterInputChange ( inputValue ) ;
167
155
}
168
156
} ,
0 commit comments