Fix new navbar item position after reordering existing items (#18516)
Closes [#2296](https://github.com/twentyhq/core-team-issues/issues/2296)
This commit is contained in:
+7
-5
@@ -6,11 +6,13 @@ export const computeInsertIndexAndPosition = (
|
||||
targetFolderId: string | null,
|
||||
targetIndex: number,
|
||||
) => {
|
||||
const itemsInFolder = currentDraft.filter(
|
||||
(item) =>
|
||||
(item.folderId ?? null) === targetFolderId &&
|
||||
!isDefined(item.userWorkspaceId),
|
||||
);
|
||||
const itemsInFolder = currentDraft
|
||||
.filter(
|
||||
(item) =>
|
||||
(item.folderId ?? null) === targetFolderId &&
|
||||
!isDefined(item.userWorkspaceId),
|
||||
)
|
||||
.sort((a, b) => a.position - b.position);
|
||||
const insertRef = itemsInFolder[targetIndex];
|
||||
const lastInFolder = itemsInFolder[itemsInFolder.length - 1];
|
||||
const flatIndex = isDefined(insertRef)
|
||||
|
||||
Reference in New Issue
Block a user