A local-first personal finance app
[AI] fix: allow clearing pre-assigned category on new transactions (#7521)
Yosof Badra4cb6dac3740
diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsxindex a594592ba1..6ccd948b41 100644--- a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx+++ b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx@@ -903,11 +903,16 @@ const TransactionEditInner = memo<TransactionEditInnerProps>(options: {categoryGroups,showHiddenCategories,+ showNoneOption: true,month: monthUtils.monthFromDate(unserializedTransaction.date,),onSelect: categoryId => {- void onUpdateInner(transactionToEdit, name, categoryId);+ void onUpdateInner(+ transactionToEdit,+ name,+ categoryId as TransactionEntity['category'],+ );},onClose: () => {onClearActiveEdit();diff --git a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsxindex d8b11ef573..4b07604529 100644--- a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx+++ b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx@@ -1,6 +1,7 @@import React from 'react';-import { useTranslation } from 'react-i18next';+import { Trans, useTranslation } from 'react-i18next';+import { Button } from '@actual-app/components/button';import { useResponsive } from '@actual-app/components/hooks/useResponsive';import { theme } from '@actual-app/components/theme';import { View } from '@actual-app/components/view';@@ -28,6 +29,7 @@ export function CategoryAutocompleteModal({onSelect,categoryGroups,showHiddenCategories,+ showNoneOption,closeOnSelect,clearOnSelect,onClose,@@ -102,6 +104,19 @@ export function CategoryAutocompleteModal({/></SheetNameProvider></View>+ {showNoneOption && (+ <View style={{ flexShrink: 0, padding: 5 }}>+ <Button+ variant="menu"+ onPress={() => {+ onSelect(null, '');+ state.close();+ }}+ >+ <Trans>Uncategorized</Trans>+ </Button>+ </View>+ )}</View></>)}diff --git a/packages/desktop-client/src/components/util/GenericInput.tsx b/packages/desktop-client/src/components/util/GenericInput.tsxindex 9c0a7fddb7..6d0832b645 100644--- a/packages/desktop-client/src/components/util/GenericInput.tsx+++ b/packages/desktop-client/src/components/util/GenericInput.tsx@@ -253,6 +253,9 @@ export const GenericInput = ({name: 'category-autocomplete',options: {onSelect: newValue => {+ if (newValue === null) {+ return;+ }if (props.multi === true) {props.onChange([...props.value, newValue]);return;diff --git a/packages/desktop-client/src/hooks/useTransactionBatchActions.ts b/packages/desktop-client/src/hooks/useTransactionBatchActions.tsindex c357eccfb3..f049647322 100644--- a/packages/desktop-client/src/hooks/useTransactionBatchActions.ts+++ b/packages/desktop-client/src/hooks/useTransactionBatchActions.ts@@ -243,6 +243,7 @@ export function useTransactionBatchActions() {name: 'category-autocomplete',options: {month: transactionsHaveSameMonth ? transactionMonth : undefined,+ showNoneOption: true,onSelect: categoryId => onChange(name, categoryId),},},diff --git a/packages/desktop-client/src/modals/modalsSlice.ts b/packages/desktop-client/src/modals/modalsSlice.tsindex 2d6644a11c..7db2dc3105 100644--- a/packages/desktop-client/src/modals/modalsSlice.ts+++ b/packages/desktop-client/src/modals/modalsSlice.ts@@ -265,9 +265,10 @@ export type Modal =options: {title?: string;categoryGroups?: CategoryGroupEntity[];- onSelect: (categoryId: string, categoryName: string) => void;+ onSelect: (categoryId: string | null, categoryName: string) => void;month?: string | undefined;showHiddenCategories?: boolean;+ showNoneOption?: boolean;closeOnSelect?: boolean;clearOnSelect?: boolean;onClose?: () => void;diff --git a/upcoming-release-notes/7521.md b/upcoming-release-notes/7521.mdnew file mode 100644index 0000000000..37209bf6d3--- /dev/null+++ b/upcoming-release-notes/7521.md@@ -0,0 +1,6 @@+---+category: Bugfixes+authors: [yosofbadr, youngcw]+---++Fix clearing pre-assigned category on new transactions in the category autocomplete modal.