Skip to content

Commit

Permalink
Merge pull request #652 from BinaryStudioAcademy/fix/bt-651-bug-fix-s…
Browse files Browse the repository at this point in the history
…uggestions-in-autocomplete-multi-selector

bt-651: [BUG] fix suggestions in Autocomplete Multi Selector
  • Loading branch information
katerynakostikova authored Sep 25, 2023
2 parents a3ae752 + 8f7d900 commit 13eb829
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ const AutocompleteMultiSelector = <T extends FieldValues>({

const filteredItems = useMemo(() => {
return items?.filter(
({ value: id }) =>
id.includes(search) &&
({ label }) =>
label.toLowerCase().includes(search.toLowerCase()) &&
!value.some(
(v: AutocompleteMultiSelectorValue) => v.value === id,
(v: AutocompleteMultiSelectorValue) =>
v.label.toLowerCase() === label.toLowerCase(),
),
);
}, [search, value, items]);
}, [value, search, items]);

return (
<>
Expand Down

0 comments on commit 13eb829

Please sign in to comment.