A local-first personal finance app
Fix bug where total selected balance is not shown when it is zero (#7460)
Kennedy242a87676bd84a0
diff --git a/packages/desktop-client/src/components/accounts/Balance.test.tsx b/packages/desktop-client/src/components/accounts/Balance.test.tsxindex 01bc10b16c..0b6fdfb8ce 100644--- a/packages/desktop-client/src/components/accounts/Balance.test.tsx+++ b/packages/desktop-client/src/components/accounts/Balance.test.tsx@@ -67,6 +67,18 @@ describe('SelectedBalance – normal transactions', () => {expect(screen.getByText('Selected balance:')).toBeInTheDocument();expect(screen.getByText('-50.00')).toBeInTheDocument();});++ test('shows balance when balance is falsy', () => {+ vi.mocked(useSheetValue).mockReturnValueOnce(null).mockReturnValueOnce(0);++ render(+ <TestProviders>+ <SelectedBalance selectedItems={new Set(['tx-123'])} />+ </TestProviders>,+ );++ expect(screen.getByText('Selected balance:')).toBeInTheDocument();+ });});describe('SelectedBalance – preview (scheduled) transactions', () => {diff --git a/packages/desktop-client/src/components/accounts/Balance.tsx b/packages/desktop-client/src/components/accounts/Balance.tsxindex 0ee6e2a666..58b7618f8c 100644--- a/packages/desktop-client/src/components/accounts/Balance.tsx+++ b/packages/desktop-client/src/components/accounts/Balance.tsx@@ -116,7 +116,7 @@ export function SelectedBalance({}}- if (!balance && !scheduleBalance) {+ if (typeof balance !== 'number' && !scheduleBalance) {return null;} else {balance = (balance ?? 0) + scheduleBalance;diff --git a/upcoming-release-notes/7460.md b/upcoming-release-notes/7460.mdnew file mode 100644index 0000000000..dd6c74685b--- /dev/null+++ b/upcoming-release-notes/7460.md@@ -0,0 +1,6 @@+---+category: Bugfixes+authors: [Kennedy242]+---++Fix bug where total selected balance is not shown when it is zero