Skip to content

Commit d4b0c80

Browse files
author
olaslo
committed
fix: sorting items
1 parent ac4f61a commit d4b0c80

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/AsideHeader/components/AllPagesPanel/utils/sortMenuItems.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import {buildExpandedFromFlatList} from './buildExpandedFromFlatList';
55
export function sortMenuItems(oldIndex: number, newIndex: number, items: MenuItemsWithGroups[]) {
66
const sortedItems = [...items];
77

8-
[sortedItems[oldIndex], sortedItems[newIndex]] = [sortedItems[newIndex], sortedItems[oldIndex]];
8+
const [movedElement] = sortedItems.splice(oldIndex, 1);
9+
10+
sortedItems.splice(newIndex, 0, movedElement);
911

1012
const expandedItems = buildExpandedFromFlatList(sortedItems);
1113
const updatedItems = expandedItems.map((item, index) => ({

0 commit comments

Comments
 (0)