Skip to content

Commit bffc64c

Browse files
authored
Merge pull request #1094 from FaheemOnHub/fix/3516/searchFunc
user search is not properly working across cloud ui
2 parents 7371ba6 + b64a5b6 commit bffc64c

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/custom/UserSearchField/UserSearchFieldInput.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
6969
const [hasInitialFocus, setHasInitialFocus] = useState(true);
7070
const [inputValue, setInputValue] = useState('');
7171
const [localUsersData, setLocalUsersData] = useState<User[]>(usersData || []);
72-
7372
useEffect(() => {
7473
setLocalUsersData(usersData || []);
7574
}, [usersData]);
@@ -88,7 +87,7 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
8887
}
8988

9089
return filteredResults;
91-
}, [searchedUsers, currentUserData, usersSearch, hasInitialFocus, localUsersData]);
90+
}, [searchedUsers, currentUserData, usersSearch, hasInitialFocus]);
9291

9392
const handleDelete = useCallback(
9493
(idToDelete: string, event: React.MouseEvent) => {
@@ -141,13 +140,14 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
141140
setHasInitialFocus(true);
142141
} else {
143142
const encodedValue = encodeURIComponent(newValue);
143+
setUsersSearch(newValue);
144144
fetchSearchedUsers(encodedValue);
145145
setError('');
146146
setOpen(true);
147147
setHasInitialFocus(false);
148148
}
149149
},
150-
[fetchSearchedUsers]
150+
[fetchSearchedUsers, setUsersSearch]
151151
);
152152
return (
153153
<>
@@ -156,30 +156,20 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
156156
style={{ width: '100%' }}
157157
open={open}
158158
options={displayOptions}
159-
getOptionLabel={() => inputValue}
159+
getOptionLabel={() => ''}
160160
isOptionEqualToValue={(option, value) => option.user_id === value.user_id}
161161
onOpen={() => setOpen(true)}
162162
onClose={() => setOpen(false)}
163163
inputValue={inputValue}
164164
onChange={handleAdd}
165165
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}
178167
loading={isUserSearchLoading}
179168
disabled={disabled}
180169
disableClearable
170+
freeSolo={false}
181171
value={undefined}
182-
selectOnFocus={false}
172+
selectOnFocus={true}
183173
blurOnSelect={true}
184174
clearOnBlur={true}
185175
popupIcon={null}

0 commit comments

Comments
 (0)