diff --git a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx index 2ac5fa7b6f1..cbd32e82b6f 100644 --- a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx @@ -22,8 +22,10 @@ import { View } from '../common/View'; import { Autocomplete, defaultFilterSuggestion } from './Autocomplete'; +type CategorySuggestion = CategoryEntity & { group?: CategoryGroupEntity }; + export type CategoryListProps = { - items: Array; + items: Array; getItemProps?: (arg: { item }) => Partial>; highlightedIndex: number; embedded: boolean; @@ -150,14 +152,7 @@ export function CategoryAutocomplete({ } return 0; }} - filterSuggestions={(suggestions, value) => { - return suggestions.filter(suggestion => { - return ( - suggestion.id === 'split' || - defaultFilterSuggestion(suggestion, value) - ); - }); - }} + filterSuggestions={filterCategorySuggestions} suggestions={categorySuggestions} renderItems={(items, getItemProps, highlightedIndex) => ( ; } + +function filterCategorySuggestions(suggestions: CategorySuggestion[], value) { + return suggestions.filter(suggestion => { + return ( + suggestion.id === 'split' || + [suggestion.name, suggestion.group.name] + .join(' ') + .toLowerCase() + .includes(value.toLowerCase()) + ); + }); +}