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.
This commit is contained in:
Abdul Rahman 2026-04-13 19:55:10 +05:30
parent 8e53ba0f4a
commit c7bc3542e4

View file

@ -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;
}