From 3bf8b99162ce9eced83e49c3e6a79359e8076edb Mon Sep 17 00:00:00 2001 From: Jessica Chowdhury Date: Wed, 26 Feb 2025 14:35:12 +0000 Subject: [PATCH] chore: reduce getParentLabel logic and update test --- packages/payload/src/fields/utilities/getParentLabels.ts | 7 +------ test/fields/collections/Array/e2e.spec.ts | 2 +- test/fields/collections/Array/index.ts | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/payload/src/fields/utilities/getParentLabels.ts b/packages/payload/src/fields/utilities/getParentLabels.ts index 0f7b134e2f..4373e915c3 100644 --- a/packages/payload/src/fields/utilities/getParentLabels.ts +++ b/packages/payload/src/fields/utilities/getParentLabels.ts @@ -18,12 +18,7 @@ export function getParentLabels( break } - let fieldLabel = field.label ?? field.name - if (field.labels && typeof field.labels === 'object' && field.labels.singular) { - fieldLabel = field.labels.singular - } - - labels.push(fieldLabel) + labels.push(field.label ?? segment) // Loop the nested fields if they exist if (field.fields) { diff --git a/test/fields/collections/Array/e2e.spec.ts b/test/fields/collections/Array/e2e.spec.ts index 1f92a32599..98e52d6c5f 100644 --- a/test/fields/collections/Array/e2e.spec.ts +++ b/test/fields/collections/Array/e2e.spec.ts @@ -158,7 +158,7 @@ describe('Array', () => { await page.click('#action-save') await expect(page.locator('.payload-toast-container')).toContainText( - 'The following field is invalid: Nested Array With Labels 1 > First Child Array 1 > Second Child Array 1 > Child Without Label 1 > Custom Text Label', + 'The following field is invalid: Parent Array Label 1 > First Child Array Label 1 > Second Child Array Label 1 > Child Without Label 1 > Custom Text Label', ) }) diff --git a/test/fields/collections/Array/index.ts b/test/fields/collections/Array/index.ts index e1ccf5d4f1..108db8cbd6 100644 --- a/test/fields/collections/Array/index.ts +++ b/test/fields/collections/Array/index.ts @@ -263,10 +263,7 @@ const ArrayFields: CollectionConfig = { { name: 'nestedArrayWithLabels', type: 'array', - labels: { - singular: 'Nested Array With Labels', - plural: 'Nested Arrays With Labels', - }, + label: 'Parent Array Label', fields: [ { name: 'firstChildArray',