@@ -69,7 +69,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
69
69
const [ hasInitialFocus , setHasInitialFocus ] = useState ( true ) ;
70
70
const [ inputValue , setInputValue ] = useState ( '' ) ;
71
71
const [ localUsersData , setLocalUsersData ] = useState < User [ ] > ( usersData || [ ] ) ;
72
-
73
72
useEffect ( ( ) => {
74
73
setLocalUsersData ( usersData || [ ] ) ;
75
74
} , [ usersData ] ) ;
@@ -88,7 +87,7 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
88
87
}
89
88
90
89
return filteredResults ;
91
- } , [ searchedUsers , currentUserData , usersSearch , hasInitialFocus , localUsersData ] ) ;
90
+ } , [ searchedUsers , currentUserData , usersSearch , hasInitialFocus ] ) ;
92
91
93
92
const handleDelete = useCallback (
94
93
( idToDelete : string , event : React . MouseEvent ) => {
@@ -141,13 +140,14 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
141
140
setHasInitialFocus ( true ) ;
142
141
} else {
143
142
const encodedValue = encodeURIComponent ( newValue ) ;
143
+ setUsersSearch ( newValue ) ;
144
144
fetchSearchedUsers ( encodedValue ) ;
145
145
setError ( '' ) ;
146
146
setOpen ( true ) ;
147
147
setHasInitialFocus ( false ) ;
148
148
}
149
149
} ,
150
- [ fetchSearchedUsers ]
150
+ [ fetchSearchedUsers , setUsersSearch ]
151
151
) ;
152
152
return (
153
153
< >
@@ -156,30 +156,20 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
156
156
style = { { width : '100%' } }
157
157
open = { open }
158
158
options = { displayOptions }
159
- getOptionLabel = { ( ) => inputValue }
159
+ getOptionLabel = { ( ) => '' }
160
160
isOptionEqualToValue = { ( option , value ) => option . user_id === value . user_id }
161
161
onOpen = { ( ) => setOpen ( true ) }
162
162
onClose = { ( ) => setOpen ( false ) }
163
163
inputValue = { inputValue }
164
164
onChange = { handleAdd }
165
165
onInputChange = { handleInputChange }
166
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
167
- // @ts -ignore
168
- filterOptions = { ( options , { inputValue } ) => {
169
- return options . filter ( ( option : User ) => {
170
- const searchStr = inputValue . toLowerCase ( ) ;
171
- return (
172
- option . first_name ?. toLowerCase ( ) . includes ( searchStr ) ||
173
- option . last_name ?. toLowerCase ( ) . includes ( searchStr ) ||
174
- option . email ?. toLowerCase ( ) . includes ( searchStr )
175
- ) ;
176
- } ) ;
177
- } }
166
+ filterOptions = { ( options ) => options }
178
167
loading = { isUserSearchLoading }
179
168
disabled = { disabled }
180
169
disableClearable
170
+ freeSolo = { false }
181
171
value = { undefined }
182
- selectOnFocus = { false }
172
+ selectOnFocus = { true }
183
173
blurOnSelect = { true }
184
174
clearOnBlur = { true }
185
175
popupIcon = { null }
0 commit comments