Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/ui/src/elements/FieldSelect/reduceFieldOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ export const reduceFieldOptions = ({
}

if (!(field.type === 'array' || field.type === 'blocks') && fieldHasSubFields(field)) {
const fieldHasLabel = 'label' in field && field.label
return [
...fieldsToUse,
...reduceFieldOptions({
fields: field.fields,
labelPrefix: combineFieldLabel({ CustomLabel, field, prefix: labelPrefix }),
labelPrefix: fieldHasLabel
? combineFieldLabel({ CustomLabel, field, prefix: labelPrefix })
: labelPrefix,
parentPath: path,
path: createNestedClientFieldPath(path, field),
permissions: fieldPermissions,
Expand All @@ -107,7 +110,7 @@ export const reduceFieldOptions = ({
fields: tab.fields,
labelPrefix,
parentPath: path,
path: isNamedTab ? createNestedClientFieldPath(path, field) : path,
path: isNamedTab ? createNestedClientFieldPath(path, tab as ClientField) : path,
permissions: fieldPermissions,
}),
]
Expand Down
22 changes: 22 additions & 0 deletions test/bulk-edit/collections/Tabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const TabsCollection: CollectionConfig = {
{
name: 'tabTab',
fields: [
{
name: 'tabText',
type: 'text',
},
{
name: 'tabTabArray',
type: 'array',
Expand All @@ -38,6 +42,24 @@ export const TabsCollection: CollectionConfig = {
},
],
},
{
name: 'noLabelGroup',
type: 'group',
label: false,
fields: [
{
type: 'row',
fields: [
{
name: 'rowText',
type: 'text',
label: 'Row Text',
admin: { width: '50%' },
},
],
},
],
},
],
},
],
Expand Down
96 changes: 96 additions & 0 deletions test/bulk-edit/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,102 @@ test.describe('Bulk Edit', () => {
.toEqual('nestedText')
})

test('should bulk edit a field inside a named tab', async () => {
const originalDoc = await payload.create({
collection: tabsSlug,
data: {
title: 'Tab Doc',
tabTab: {
tabText: 'original value',
},
},
})

await page.goto(tabsUrl.list)
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('limit=')

await addListFilter({
page,
fieldLabel: 'ID',
operatorLabel: 'equals',
value: originalDoc.id,
})

await page.locator('table tbody tr.row-1 input[type="checkbox"]').check()
await page
.locator('.list-selection__actions .btn', {
hasText: 'Edit',
})
.click()

const bulkEditForm = page.locator('form.edit-many__form')
await expect(bulkEditForm).toBeVisible()

await selectInput({
selectLocator: bulkEditForm.locator('.react-select'),
options: ['Tab Text'],
multiSelect: true,
})

await bulkEditForm.getByLabel('Tab Text').fill('updated value')
await bulkEditForm.locator('button[type="submit"]').click()

await expect(bulkEditForm).toBeHidden()

const updatedDocQuery = await payload.find({
collection: tabsSlug,
where: {
id: {
equals: originalDoc.id,
},
},
})
const updatedDoc = updatedDocQuery.docs[0]

await expect
.poll(() => updatedDoc?.tabTab?.tabText, { timeout: POLL_TOPASS_TIMEOUT })
.toEqual('updated value')

await payload.delete({ collection: tabsSlug, id: originalDoc.id })
})

test('should show clean labels for fields inside label-false groups and rows', async () => {
const doc = await payload.create({
collection: tabsSlug,
data: { title: 'Label Test Doc' },
})

await page.goto(tabsUrl.list)
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('limit=')

await addListFilter({
page,
fieldLabel: 'ID',
operatorLabel: 'equals',
value: doc.id,
})

await page.locator('table tbody tr.row-1 input[type="checkbox"]').check()
await page
.locator('.list-selection__actions .btn', {
hasText: 'Edit',
})
.click()

const bulkEditForm = page.locator('form.edit-many__form')
await expect(bulkEditForm).toBeVisible()

await bulkEditForm.locator('.field-select .rs__control').click()

// The option must match exactly — no spurious "> >" prefix
const option = bulkEditForm.locator('.field-select .rs__option', {
hasText: exactText('Row Text'),
})
await expect(option).toBeVisible()

await payload.delete({ collection: tabsSlug, id: doc.id })
})

test('should preserve beforeInput components when selecting multiple fields', async () => {
await deleteAllPosts()
await createPost({ title: 'Post 1' })
Expand Down
23 changes: 23 additions & 0 deletions test/bulk-edit/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export interface Config {
globals: {};
globalsSelect: {};
locale: null;
widgets: {
collections: CollectionsWidget;
};
user: User;
jobs: {
tasks: unknown;
Expand Down Expand Up @@ -168,13 +171,17 @@ export interface Tab {
id: string;
title?: string | null;
tabTab?: {
tabText?: string | null;
tabTabArray?:
| {
tabTabArrayText?: string | null;
id?: string | null;
}[]
| null;
};
noLabelGroup?: {
rowText?: string | null;
};
updatedAt: string;
createdAt: string;
}
Expand Down Expand Up @@ -338,13 +345,19 @@ export interface TabsSelect<T extends boolean = true> {
tabTab?:
| T
| {
tabText?: T;
tabTabArray?:
| T
| {
tabTabArrayText?: T;
id?: T;
};
};
noLabelGroup?:
| T
| {
rowText?: T;
};
updatedAt?: T;
createdAt?: T;
}
Expand Down Expand Up @@ -410,6 +423,16 @@ export interface PayloadMigrationsSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "collections_widget".
*/
export interface CollectionsWidget {
data?: {
[k: string]: unknown;
};
width: 'full';
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auth".
Expand Down