From c7bc3542e4607eb835f360c0da6879b294224ed9 Mon Sep 17 00:00:00 2001 From: Abdul Rahman Date: Mon, 13 Apr 2026 19:55:10 +0530 Subject: [PATCH] Refactor folder navigation menu item URL matching logic - Simplified the logic for determining if a folder navigation menu item matches the current URL by consolidating the retrieval of object metadata. - Removed redundant checks and streamlined the flow for better readability and maintainability. --- ...rNavigationMenuItemMatchUrlForSelection.ts | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/packages/twenty-front/src/modules/navigation-menu-item/display/folder/utils/doesFolderNavigationMenuItemMatchUrlForSelection.ts b/packages/twenty-front/src/modules/navigation-menu-item/display/folder/utils/doesFolderNavigationMenuItemMatchUrlForSelection.ts index 4f4c48dee4a..9675dd2f7b1 100644 --- a/packages/twenty-front/src/modules/navigation-menu-item/display/folder/utils/doesFolderNavigationMenuItemMatchUrlForSelection.ts +++ b/packages/twenty-front/src/modules/navigation-menu-item/display/folder/utils/doesFolderNavigationMenuItemMatchUrlForSelection.ts @@ -39,33 +39,24 @@ export const doesFolderNavigationMenuItemMatchUrlForSelection = ({ computedLink, ); - const objectMetadataForRecordShowMatch = - !matchesByLink && - folderChildNavigationMenuItem.type === NavigationMenuItemType.OBJECT - ? getObjectMetadataForNavigationMenuItem( - folderChildNavigationMenuItem, - objectMetadataItems, - views, - ) - : undefined; - - const matchesByRecordShow = - isDefined(objectMetadataForRecordShowMatch) && - matchesRecordShowPathForObject( - currentPath, - objectMetadataForRecordShowMatch.nameSingular, - ); - - if (!matchesByLink && !matchesByRecordShow) { - return false; - } - const objectMetadataForFolderChild = getObjectMetadataForNavigationMenuItem( folderChildNavigationMenuItem, objectMetadataItems, views, ); + const matchesByRecordShow = + !matchesByLink && + isDefined(objectMetadataForFolderChild) && + matchesRecordShowPathForObject( + currentPath, + objectMetadataForFolderChild.nameSingular, + ); + + if (!matchesByLink && !matchesByRecordShow) { + return false; + } + if (!isDefined(objectMetadataForFolderChild)) { return true; }