diff --git a/packages/twenty-front/src/modules/views/utils/getObjectMetadataItemViews.ts b/packages/twenty-front/src/modules/views/utils/getObjectMetadataItemViews.ts index da5c5b0398..ebc1f502f1 100644 --- a/packages/twenty-front/src/modules/views/utils/getObjectMetadataItemViews.ts +++ b/packages/twenty-front/src/modules/views/utils/getObjectMetadataItemViews.ts @@ -4,18 +4,11 @@ export const getObjectMetadataItemViews = ( viewObjectMetadataId: string, views: GraphQLView[], ) => { - const indexView = views.find( - (view) => - view.key === 'INDEX' && view.objectMetadataId === viewObjectMetadataId, - ); - return [ - ...views - .filter((view) => view.objectMetadataId === viewObjectMetadataId) - .filter((view) => view.key !== 'INDEX'), + ...views.filter((view) => view.objectMetadataId === viewObjectMetadataId), ] .sort((a, b) => a.position - b.position) - .concat(indexView ? [indexView] : []) + .map((view) => ({ id: view.id, name: view.name, diff --git a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx index 91b18694dd..0fc67d6ab9 100644 --- a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx +++ b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx @@ -64,9 +64,6 @@ export const ViewPickerListContent = () => { const { getIcon } = useIcons(); const indexView = viewsOnCurrentObject.find((view) => view.key === 'INDEX'); - const viewsOnCurrentObjectWithoutIndex = viewsOnCurrentObject.filter( - (view) => view.key !== 'INDEX', - ); const handleDragEnd = useCallback( (result: DropResult) => { @@ -89,49 +86,41 @@ export const ViewPickerListContent = () => { ( - ) => - handleEditViewButtonClick(event, view.id), - }, - ].filter(isDefined)} - isIconDisplayedOnHoverOnly - onClick={() => handleViewSelect(view.id)} - LeftIcon={getIcon(view.icon)} - text={view.name} - /> - } - /> - ), - )} + draggableItems={viewsOnCurrentObject.map((view, index) => ( + ) => + handleEditViewButtonClick(event, view.id), + }, + ].filter(isDefined) + } + isIconDisplayedOnHoverOnly={ + indexView?.id === view.id ? false : true + } + onClick={() => handleViewSelect(view.id)} + LeftIcon={getIcon(view.icon)} + text={view.name} + /> + } + /> + ))} /> - {indexView && ( - handleViewSelect(indexView.id)} - LeftIcon={getIcon(indexView.icon)} - text={indexView.name} - accent="placeholder" - isDragDisabled - /> - )}