diff --git a/packages/desktop-client/src/components/budget/BudgetTable.jsx b/packages/desktop-client/src/components/budget/BudgetTable.jsx index 76ff7a60545534478cf9f6c02e359c7fce73dce8..24d72bf871838cb7124cdb2bb9f2579c09d5d485 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 error onReorderGroup({ 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.ts index e0153e152e7d23b415d7506ff8d21b28a549c020..a3658651efaf002de922d1e8c0585d1e472f1af5 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 end diff --git a/upcoming-release-notes/3241.md b/upcoming-release-notes/3241.md new file mode 100644 index 0000000000000000000000000000000000000000..8da4780f026a7fba5c8c1378c3131d5e1f2d1dc3 --- /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