Consistent Sorting of Workspace Buttons Across Browsers (#3222)

Fixed inconsistent workspace order in different browers (#3217)
This commit is contained in:
Jeong Min Cho 2024-01-03 23:59:20 +09:00 committed by GitHub
parent 67fca68480
commit f4405b1b38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,16 +17,16 @@ export const ObjectMetadataNavItems = () => {
.filter((item) => .filter((item) =>
['person', 'company', 'opportunity'].includes(item.nameSingular), ['person', 'company', 'opportunity'].includes(item.nameSingular),
) )
.sort((objectMetadataItemA, _) => { .sort((objectMetadataItemA, objectMetadataItemB) => {
if (objectMetadataItemA.nameSingular === 'person') { const order = ['person', 'company', 'opportunity'];
return -1; const indexA = order.indexOf(objectMetadataItemA.nameSingular);
const indexB = order.indexOf(objectMetadataItemB.nameSingular);
if (indexA === -1 || indexB === -1) {
return objectMetadataItemA.nameSingular.localeCompare(
objectMetadataItemB.nameSingular,
);
} }
return indexA - indexB;
if (objectMetadataItemA.nameSingular === 'opportunity') {
return 1;
}
return 0;
}), }),
...activeObjectMetadataItems ...activeObjectMetadataItems
.filter( .filter(