Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search category autocomplete includes group category #2731

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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))
);
});
}}
Expand Down
38 changes: 38 additions & 0 deletions packages/desktop-client/src/components/settings/Autocomplete.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Setting
primaryAction={
<Text style={{ display: 'flex' }}>
<Checkbox
id="settings-autocompleteCategoryMatchGroup"
checked={!!autocompleteCategoryMatchGroup}
onChange={e =>
setAutocompleteCategoryMatchGroupPref(e.currentTarget.checked)
}
/>
<label htmlFor="settings-autocompleteCategoryMatchGroup">
Category autocomplete search match on category group names
</label>
</Text>
}
>
<Text>
<strong>Autocomplete</strong> change the behavior of the autocomplete
dropdowns.
</Text>
</Setting>
);
}
2 changes: 2 additions & 0 deletions packages/desktop-client/src/components/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -174,6 +175,7 @@ export function Settings() {

<AdvancedToggle>
<AdvancedAbout />
<AutocompleteSettings />
<ResetCache />
<ResetSync />
<FixSplits />
Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/src/types/prefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type LocalPrefs = Partial<
reportsViewSummary: boolean;
reportsViewLabel: boolean;
'mobile.showSpentColumn': boolean;
autocompleteCategoryMatchGroup: boolean;
} & Record<`flags.${FeatureFlag}`, boolean>
>;

Expand Down
5 changes: 5 additions & 0 deletions upcoming-release-notes/2731.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
category: Enhancements
authors: [Wizmaster]
---
Add option to have the Category autocomplete match on Category Group names
Loading