mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-28 10:33:02 -05:00
Fix off-by-one error when placing category into 2nd-to-last place (#3241)
* Fix off-by-one error when placing category into 2nd-to-last place Signed-off-by: JL102 <jordanlees@mailbox.org> * Add changelog file Signed-off-by: JL102 <jordanlees@mailbox.org> --------- Signed-off-by: JL102 <jordanlees@mailbox.org>
This commit is contained in:
@@ -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),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
6
upcoming-release-notes/3241.md
Normal file
6
upcoming-release-notes/3241.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [JL102]
|
||||
---
|
||||
|
||||
Fixed category appearing in last slot when you drag it to the second-to-last slot
|
||||
Reference in New Issue
Block a user