Skip to content

Commit 6209c54

Browse files
authored
Merge pull request #892 from amitamrutiya/fix-share
fix: share is not working issue
2 parents 0320125 + 283c3e1 commit 6209c54

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/custom/UserSearchField/UserSearchField.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Autocomplete from '@mui/material/Autocomplete';
22
import CircularProgress from '@mui/material/CircularProgress';
3+
import { debounce } from 'lodash';
34
import React, { useState } from 'react';
45
import { Avatar, Box, Chip, Grid, TextField, Tooltip, Typography } from '../../base';
56
import { iconSmall } from '../../constants/iconsSizes';
@@ -88,21 +89,22 @@ const UserShareSearch: React.FC<UserSearchFieldProps> = ({
8889
}
8990
};
9091

91-
const handleInputChange = (_event: React.SyntheticEvent<Element, Event>, value: string) => {
92-
if (value === '') {
93-
setOptions([]);
94-
setOpen(false);
95-
} else {
96-
setSearchUserLoading(true);
97-
fetchSuggestions(value).then((filteredData) => {
98-
setOptions(filteredData);
92+
const handleInputChange = debounce(
93+
async (_event: React.SyntheticEvent<Element, Event>, value: string) => {
94+
if (value === '') {
95+
setOptions([]);
96+
setOpen(false);
97+
} else {
98+
setSearchUserLoading(true);
99+
const suggestions = await fetchSuggestions(value);
100+
setOptions(suggestions);
99101
setSearchUserLoading(false);
100-
});
101-
setError(false);
102-
setOpen(true);
103-
}
104-
};
105-
102+
setError(false);
103+
setOpen(true);
104+
}
105+
},
106+
300
107+
);
106108
/**
107109
* Clone customUsersList component to pass necessary props
108110
*/

0 commit comments

Comments
 (0)