diff --git a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx index 3f1d16cdade..469ab946a1e 100644 --- a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx @@ -166,6 +166,9 @@ export function CategoryAutocomplete({ ...props }: CategoryAutocompleteProps) { const { grouped: defaultCategoryGroups = [] } = useCategories(); + const [autocompleteCategoryMatchGroup = false] = useLocalPref( + 'autocompleteCategoryMatchGroup', + ); const categorySuggestions: CategoryAutocompleteItem[] = useMemo( () => (categoryGroups || defaultCategoryGroups).reduce( @@ -201,7 +204,10 @@ export function CategoryAutocomplete({ return suggestions.filter(suggestion => { return ( suggestion.id === 'split' || - defaultFilterSuggestion(suggestion, value) + defaultFilterSuggestion(suggestion, value) || + (autocompleteCategoryMatchGroup && + suggestion.group && + defaultFilterSuggestion(suggestion.group, value)) ); }); }} diff --git a/packages/desktop-client/src/components/settings/Autocomplete.tsx b/packages/desktop-client/src/components/settings/Autocomplete.tsx new file mode 100644 index 00000000000..87534bcea69 --- /dev/null +++ b/packages/desktop-client/src/components/settings/Autocomplete.tsx @@ -0,0 +1,38 @@ +import React from 'react'; + +import { useLocalPref } from '../../hooks/useLocalPref'; +import { Text } from '../common/Text'; +import { Checkbox } from '../forms'; + +import { Setting } from './UI'; + +export function AutocompleteSettings() { + const [ + autocompleteCategoryMatchGroup = false, + setAutocompleteCategoryMatchGroupPref, + ] = useLocalPref('autocompleteCategoryMatchGroup'); + + return ( + + + setAutocompleteCategoryMatchGroupPref(e.currentTarget.checked) + } + /> + + + } + > + + Autocomplete change the behavior of the autocomplete + dropdowns. + + + ); +} diff --git a/packages/desktop-client/src/components/settings/index.tsx b/packages/desktop-client/src/components/settings/index.tsx index 1137aa4e597..510a6e90bc9 100644 --- a/packages/desktop-client/src/components/settings/index.tsx +++ b/packages/desktop-client/src/components/settings/index.tsx @@ -22,6 +22,7 @@ import { FormField, FormLabel } from '../forms'; import { Page } from '../Page'; import { useServerVersion } from '../ServerContext'; +import { AutocompleteSettings } from './Autocomplete'; import { EncryptionSettings } from './Encryption'; import { ExperimentalFeatures } from './Experimental'; import { ExportBudget } from './Export'; @@ -174,6 +175,7 @@ export function Settings() { + diff --git a/packages/loot-core/src/types/prefs.d.ts b/packages/loot-core/src/types/prefs.d.ts index d3632e0308a..c91ddd974f0 100644 --- a/packages/loot-core/src/types/prefs.d.ts +++ b/packages/loot-core/src/types/prefs.d.ts @@ -55,6 +55,7 @@ export type LocalPrefs = Partial< reportsViewSummary: boolean; reportsViewLabel: boolean; 'mobile.showSpentColumn': boolean; + autocompleteCategoryMatchGroup: boolean; } & Record<`flags.${FeatureFlag}`, boolean> >; diff --git a/upcoming-release-notes/2731.md b/upcoming-release-notes/2731.md new file mode 100644 index 00000000000..941edcd8738 --- /dev/null +++ b/upcoming-release-notes/2731.md @@ -0,0 +1,5 @@ +--- +category: Enhancements +authors: [Wizmaster] +--- +Add option to have the Category autocomplete match on Category Group names \ No newline at end of file