From f4405b1b38de6e2e3f8ca8a3e6566fa6a29ab6c7 Mon Sep 17 00:00:00 2001 From: Jeong Min Cho Date: Wed, 3 Jan 2024 23:59:20 +0900 Subject: [PATCH] Consistent Sorting of Workspace Buttons Across Browsers (#3222) Fixed inconsistent workspace order in different browers (#3217) --- .../components/ObjectMetadataNavItems.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx index 130419aa8e..b4de41fe78 100644 --- a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx +++ b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx @@ -17,16 +17,16 @@ export const ObjectMetadataNavItems = () => { .filter((item) => ['person', 'company', 'opportunity'].includes(item.nameSingular), ) - .sort((objectMetadataItemA, _) => { - if (objectMetadataItemA.nameSingular === 'person') { - return -1; + .sort((objectMetadataItemA, objectMetadataItemB) => { + const order = ['person', 'company', 'opportunity']; + const indexA = order.indexOf(objectMetadataItemA.nameSingular); + const indexB = order.indexOf(objectMetadataItemB.nameSingular); + if (indexA === -1 || indexB === -1) { + return objectMetadataItemA.nameSingular.localeCompare( + objectMetadataItemB.nameSingular, + ); } - - if (objectMetadataItemA.nameSingular === 'opportunity') { - return 1; - } - - return 0; + return indexA - indexB; }), ...activeObjectMetadataItems .filter(