chore: reduce getParentLabel logic and update test

This commit is contained in:
Jessica Chowdhury
2025-02-26 14:35:12 +00:00
parent 890b400635
commit 3bf8b99162
3 changed files with 3 additions and 11 deletions

View File

@@ -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) {

View File

@@ -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',
)
})

View File

@@ -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',