@@ -73,7 +73,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
73
73
setLocalUsersData ( usersData || [ ] ) ;
74
74
} , [ usersData ] ) ;
75
75
76
- // Combine current user with search results and filter appropriately
77
76
const displayOptions = useMemo ( ( ) => {
78
77
if ( hasInitialFocus && ! usersSearch && currentUserData ) {
79
78
return [ currentUserData ] ;
@@ -159,23 +158,23 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
159
158
id = "user-search-field"
160
159
style = { { width : '100%' } }
161
160
open = { open }
161
+ options = { displayOptions }
162
+ getOptionLabel = { ( ) => inputValue }
163
+ isOptionEqualToValue = { ( option , value ) => option . id === value . id }
162
164
onOpen = { ( ) => setOpen ( true ) }
163
165
onClose = { ( ) => setOpen ( false ) }
164
166
inputValue = { inputValue }
165
167
onChange = { handleAdd }
166
168
onInputChange = { handleInputChange }
167
- options = { displayOptions }
168
- getOptionLabel = { ( ) => inputValue }
169
- isOptionEqualToValue = { ( option , value ) => option . id === value . id }
170
169
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
171
170
// @ts -ignore
172
171
filterOptions = { ( options , { inputValue } ) => {
173
172
return options . filter ( ( option : User ) => {
174
173
const searchStr = inputValue . toLowerCase ( ) ;
175
174
return (
176
- option . first_name . toLowerCase ( ) . includes ( searchStr ) ||
177
- option . last_name . toLowerCase ( ) . includes ( searchStr ) ||
178
- option . email . toLowerCase ( ) . includes ( searchStr )
175
+ option . first_name ? .toLowerCase ( ) . includes ( searchStr ) ||
176
+ option . last_name ? .toLowerCase ( ) . includes ( searchStr ) ||
177
+ option . email ? .toLowerCase ( ) . includes ( searchStr )
179
178
) ;
180
179
} ) ;
181
180
} }
@@ -187,6 +186,7 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
187
186
blurOnSelect = { true }
188
187
clearOnBlur = { true }
189
188
popupIcon = { null }
189
+ forcePopupIcon = { false }
190
190
noOptionsText = { isUserSearchLoading ? 'Loading...' : 'No users found' }
191
191
renderInput = { ( params ) => (
192
192
< TextField
@@ -199,7 +199,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
199
199
endAdornment : (
200
200
< React . Fragment >
201
201
{ isUserSearchLoading ? < CircularProgress color = "inherit" size = { 20 } /> : null }
202
- { params . InputProps . endAdornment }
203
202
</ React . Fragment >
204
203
)
205
204
} }
@@ -307,12 +306,7 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
307
306
< Typography
308
307
onClick = { ( ) => setShowAllUsers ( ! showAllUsers ) }
309
308
sx = { {
310
- cursor : 'pointer' ,
311
- color : 'white' ,
312
- fontWeight : '600' ,
313
- '&:hover' : {
314
- color : 'black'
315
- }
309
+ cursor : 'pointer'
316
310
} }
317
311
>
318
312
{ showAllUsers ? '(hide)' : `(+${ localUsersData . length - 1 } )` }
0 commit comments