From 79767f6a229d4c88b68c6090f7f98174773c22da Mon Sep 17 00:00:00 2001 From: Jessica Chowdhury Date: Fri, 28 Feb 2025 15:17:34 +0000 Subject: [PATCH] chore: fix getParentLabels for blocks --- .../payload/src/fields/utilities/getParentLabels.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/payload/src/fields/utilities/getParentLabels.ts b/packages/payload/src/fields/utilities/getParentLabels.ts index 4373e915c3..6ae0f1845c 100644 --- a/packages/payload/src/fields/utilities/getParentLabels.ts +++ b/packages/payload/src/fields/utilities/getParentLabels.ts @@ -13,19 +13,17 @@ export function getParentLabels( } // Find the field that matches the current path segment - const field = currentFields.find((f) => f.name === segment) + const field = currentFields?.find((f) => { + if (f.name === segment || f.slug === segment) {return f} + }) + if (!field) { break } labels.push(field.label ?? segment) - // Loop the nested fields if they exist - if (field.fields) { - currentFields = field.fields - } else { - break - } + currentFields = field.fields ?? field.blocks ?? [] } return labels