From e5dba78be7aa32b5bfe99668237f00961589317e Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Thu, 28 Sep 2023 18:33:04 -0700 Subject: [PATCH] Update blank category name behavior --- .../components/budget/MobileBudgetTable.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/desktop-client/src/components/budget/MobileBudgetTable.js b/packages/desktop-client/src/components/budget/MobileBudgetTable.js index b86b226f00f..6828335a9d8 100644 --- a/packages/desktop-client/src/components/budget/MobileBudgetTable.js +++ b/packages/desktop-client/src/components/budget/MobileBudgetTable.js @@ -311,10 +311,14 @@ const ExpenseCategory = memo(function ExpenseCategory({ let tooltip = useTooltip(); let onTooltipClose = () => { - onSave?.({ - ...category, - name: categoryName, - }); + if (categoryName) { + onSave?.({ + ...category, + name: categoryName, + }); + } else { + setCategoryName(category.name); + } tooltip.close(); }; @@ -378,9 +382,7 @@ const ExpenseCategory = memo(function ExpenseCategory({ } placeholder="Category Name" value={categoryName} - onUpdate={name => - setCategoryName(name ? name : category.name) - } + onUpdate={setCategoryName} onEnter={onTooltipClose} />