A local-first personal finance app
[AI] Fix clearing the payee when editing a transaction on mobile (#8926)
Daniel Nieto34597d703f44
diff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts b/packages/desktop-client/e2e/transactions.mobile.test.tsindex d4b343b07a..28f8d6cada 100644--- a/packages/desktop-client/e2e/transactions.mobile.test.ts+++ b/packages/desktop-client/e2e/transactions.mobile.test.ts@@ -79,6 +79,36 @@ test.describe('Mobile Transactions', () => {- textbox [disabled]: just a note`);});+ test('removes the payee from a new transaction', async () => {+ const accountsPage = await navigation.goToAccountsPage();+ const accountPage = await accountsPage.openNthAccount(2);+ const transactionEntryPage = await accountPage.clickCreateTransaction();++ await transactionEntryPage.fillAmount('12.34');+ // Click anywhere to cancel active edit.+ await transactionEntryPage.header.click();+ await transactionEntryPage.fillField(+ page.getByTestId('payee-field'),+ 'Kroger',+ );+ await expect(page.getByTestId('payee-field')).toContainText('Kroger');++ // Reopen the payee selector and clear it with the "No payee" option.+ await page.getByTestId('payee-field').click();+ await page.getByRole('button', { name: 'No payee' }).click();+ await expect(page.getByTestId('payee-field')).not.toContainText('Kroger');++ await transactionEntryPage.fillField(+ page.getByTestId('category-field'),+ 'Clothing',+ );+ await transactionEntryPage.createTransaction();++ await expect(accountPage.transactions.nth(0)).toHaveText(+ '(No payee)Clothing-12.34',+ );+ });+test('creates a transaction from `/accounts/:id` page', async () => {const accountsPage = await navigation.goToAccountsPage();const accountPage = await accountsPage.openNthAccount(2);diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsxindex 3c6b9c39ec..d7a5cdcc17 100644--- a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx+++ b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx@@ -994,6 +994,7 @@ const TransactionEditInner = memo<TransactionEditInnerProps>(modal: {name: 'payee-autocomplete',options: {+ showNoneOption: !!transactionToEdit.payee,onSelect: payeeId => {void onUpdateInner(transactionToEdit, name, payeeId);},diff --git a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsxindex 0f3301390b..82c1b4c2a1 100644--- a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx+++ b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx@@ -1,8 +1,10 @@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';import { PayeeAutocomplete } from '#components/autocomplete/PayeeAutocomplete';import {@@ -23,6 +25,7 @@ type PayeeAutocompleteModalProps = Extract<export function PayeeAutocompleteModal({onSelect,+ showNoneOption,onClose,}: PayeeAutocompleteModalProps) {const { t } = useTranslation();@@ -69,20 +72,37 @@ export function PayeeAutocompleteModal({}/>)}- <PayeeAutocomplete- payees={payees}- accounts={accounts}- focused- embedded- closeOnBlur={false}- onClose={() => state.close()}- onManagePayees={onManagePayees}- showManagePayees={!isNarrowWidth}- showMakeTransfer={!isNarrowWidth}- {...defaultAutocompleteProps}- onSelect={onSelect}- value={null}- />+ <View>+ <View style={{ flex: 1 }}>+ <PayeeAutocomplete+ payees={payees}+ accounts={accounts}+ focused+ embedded+ closeOnBlur={false}+ onClose={() => state.close()}+ onManagePayees={onManagePayees}+ showManagePayees={!isNarrowWidth}+ showMakeTransfer={!isNarrowWidth}+ {...defaultAutocompleteProps}+ onSelect={onSelect}+ value={null}+ />+ </View>+ {showNoneOption && (+ <View style={{ flexShrink: 0, padding: 5 }}>+ <Button+ variant="menu"+ onPress={() => {+ onSelect(null);+ state.close();+ }}+ >+ <Trans>No payee</Trans>+ </Button>+ </View>+ )}+ </View></>)}</Modal>diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.tsxindex e92e618d62..dc00c4f4e7 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.tsx@@ -695,7 +695,7 @@ function PayeeCell({modal: {name: 'payee-autocomplete',options: {- onSelect: (payeeId: PayeeEntity['id']) => {+ onSelect: (payeeId: PayeeEntity['id'] | null) => {onUpdate('payee', payeeId);},},diff --git a/packages/desktop-client/src/components/util/GenericInput.tsx b/packages/desktop-client/src/components/util/GenericInput.tsxindex d49b863bbe..6dd99beb2e 100644--- a/packages/desktop-client/src/components/util/GenericInput.tsx+++ b/packages/desktop-client/src/components/util/GenericInput.tsx@@ -170,6 +170,9 @@ export const GenericInput = ({name: 'payee-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/modals/modalsSlice.ts b/packages/desktop-client/src/modals/modalsSlice.tsindex 2833e36c32..13c888b53f 100644--- a/packages/desktop-client/src/modals/modalsSlice.ts+++ b/packages/desktop-client/src/modals/modalsSlice.ts@@ -316,7 +316,8 @@ export type Modal =| {name: 'payee-autocomplete';options: {- onSelect: (payeeId: string) => void;+ onSelect: (payeeId: string | null) => void;+ showNoneOption?: boolean;onClose?: () => void;};}diff --git a/upcoming-release-notes/fix-mobile-clear-payee.md b/upcoming-release-notes/fix-mobile-clear-payee.mdnew file mode 100644index 0000000000..1fefa2ccf6--- /dev/null+++ b/upcoming-release-notes/fix-mobile-clear-payee.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [danielnieto]+---++Fix clearing the payee when editing a transaction on mobile