A local-first personal finance app
Fix off-by-one error when placing category into 2nd-to-last place (#3241)
Jordan Lees119d0b339dfa
diff --git a/packages/desktop-client/src/components/budget/BudgetTable.jsx b/packages/desktop-client/src/components/budget/BudgetTable.jsxindex 76ff7a6054..24d72bf871 100644--- a/packages/desktop-client/src/components/budget/BudgetTable.jsx+++ b/packages/desktop-client/src/components/budget/BudgetTable.jsx@@ -9,7 +9,12 @@ import { BudgetCategories } from './BudgetCategories';import { BudgetSummaries } from './BudgetSummaries';import { BudgetTotals } from './BudgetTotals';import { MonthsProvider } from './MonthsContext';-import { findSortDown, findSortUp, getScrollbarWidth } from './util';+import {+ findSortDown,+ findSortUp,+ getScrollbarWidth,+ separateGroups,+} from './util';export function BudgetTable(props) {const {@@ -86,9 +91,10 @@ export function BudgetTable(props) {};const _onReorderGroup = (id, dropPos, targetId) => {+ const [expenseGroups] = separateGroups(categoryGroups); // exclude Income group from sortable groups to fix off-by-one erroronReorderGroup({id,- ...findSortDown(categoryGroups, dropPos, targetId),+ ...findSortDown(expenseGroups, dropPos, targetId),});};diff --git a/packages/desktop-client/src/components/budget/util.ts b/packages/desktop-client/src/components/budget/util.tsindex e0153e152e..a3658651ef 100644--- a/packages/desktop-client/src/components/budget/util.ts+++ b/packages/desktop-client/src/components/budget/util.ts@@ -103,7 +103,7 @@ export function findSortDown(}const newIdx = idx + 1;- if (newIdx < arr.length - 1) {+ if (newIdx < arr.length) {return { targetId: arr[newIdx].id };} else {// Move to the enddiff --git a/upcoming-release-notes/3241.md b/upcoming-release-notes/3241.mdnew file mode 100644index 0000000000..8da4780f02--- /dev/null+++ b/upcoming-release-notes/3241.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [JL102]+---++Fixed category appearing in last slot when you drag it to the second-to-last slot