From 575007ebeb206c3eb3c406f2ab0b967c5fe0a5ac Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Thu, 18 Jan 2024 16:05:32 -0800 Subject: [PATCH] Fix sort bug --- .../src/components/budget/BudgetTable.jsx | 11 +++-------- packages/desktop-client/src/components/budget/util.ts | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/desktop-client/src/components/budget/BudgetTable.jsx b/packages/desktop-client/src/components/budget/BudgetTable.jsx index 3000ebb1af4..587737fcd1b 100644 --- a/packages/desktop-client/src/components/budget/BudgetTable.jsx +++ b/packages/desktop-client/src/components/budget/BudgetTable.jsx @@ -57,14 +57,9 @@ export class BudgetTable extends Component { }); } } else { - let targetGroup; - - for (const group of categoryGroups) { - if (group.categories.find(cat => cat.id === targetId)) { - targetGroup = group; - break; - } - } + const targetGroup = categoryGroups.find(g => + g.categories.find(c => c.id === targetId), + ); this.props.onReorderCategory({ id, diff --git a/packages/desktop-client/src/components/budget/util.ts b/packages/desktop-client/src/components/budget/util.ts index 5039526ffe5..7ef871b7324 100644 --- a/packages/desktop-client/src/components/budget/util.ts +++ b/packages/desktop-client/src/components/budget/util.ts @@ -92,7 +92,7 @@ export function findSortDown( } const newIdx = idx + 1; - if (newIdx < arr.length - 1) { + if (newIdx <= arr.length - 1) { return { targetId: arr[newIdx].id }; } else { // Move to the end