Skip to content

Commit

Permalink
Fix sort bug
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Jan 19, 2024
1 parent e815d63 commit 575007e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions packages/desktop-client/src/components/budget/BudgetTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/budget/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 575007e

Please sign in to comment.