From d24d8fb7dd2b7fb007bd073e4f76fcb1bffffce1 Mon Sep 17 00:00:00 2001 From: Nithun Harikrishnan <nithun@gmail.com> Date: Sat, 4 Feb 2023 12:07:49 -0800 Subject: [PATCH] Fixes editing closed account names issue #616 (#620) * Fixes editing closed account names issue #616 * Adds null, empty and whitespace checks * Fix whitespacing issue --- .../src/components/accounts/Account.js | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/desktop-client/src/components/accounts/Account.js b/packages/desktop-client/src/components/accounts/Account.js index 5349d1591..f8fb0762d 100644 --- a/packages/desktop-client/src/components/accounts/Account.js +++ b/packages/desktop-client/src/components/accounts/Account.js @@ -717,7 +717,9 @@ const AccountHeader = React.memo( marginBottom: 5 }} > - {accountName} + {account && account.closed + ? 'Closed: ' + accountName + : accountName} </View> {account && <NotesButton id={`account-${account.id}`} />} @@ -739,7 +741,9 @@ const AccountHeader = React.memo( <View style={{ fontSize: 25, fontWeight: 500, marginBottom: 5 }} > - {accountName} + {account && account.closed + ? 'Closed: ' + accountName + : accountName} </View> )} </View> @@ -1319,12 +1323,14 @@ class AccountInternal extends React.PureComponent { }; onSaveName = name => { - const accountId = this.props.accountId; - const account = this.props.accounts.find( - account => account.id === accountId - ); - this.props.updateAccount({ ...account, name }); - this.setState({ editingName: false }); + if (name.trim().length) { + const accountId = this.props.accountId; + const account = this.props.accounts.find( + account => account.id === accountId + ); + this.props.updateAccount({ ...account, name }); + this.setState({ editingName: false }); + } }; onToggleExtraBalances = () => { @@ -1391,7 +1397,7 @@ class AccountInternal extends React.PureComponent { return null; } - return (account.closed ? 'Closed: ' : '') + account.name; + return account.name; } getBalanceQuery(account, id) { -- GitLab