diff --git a/packages/payload/src/utilities/fieldSchemaToJSON.ts b/packages/payload/src/utilities/fieldSchemaToJSON.ts index c4ec03c34..2c496ac32 100644 --- a/packages/payload/src/utilities/fieldSchemaToJSON.ts +++ b/packages/payload/src/utilities/fieldSchemaToJSON.ts @@ -74,7 +74,7 @@ export const fieldSchemaToJSON = (fields: Field[]): FieldSchemaJSON => { tabFields.push({ name: tab.name, fields: fieldSchemaToJSON(tab.fields), - type: 'tab', + type: field.type, }) return } diff --git a/test/live-preview/collections/Pages.ts b/test/live-preview/collections/Pages.ts index b92aef129..0325f1edd 100644 --- a/test/live-preview/collections/Pages.ts +++ b/test/live-preview/collections/Pages.ts @@ -121,6 +121,23 @@ export const Pages: CollectionConfig = { }, ], }, + { + label: 'Named Tabs', + type: 'tabs', + tabs: [ + { + name: 'tab', + label: 'Tab', + fields: [ + { + name: 'relationshipInTab', + type: 'relationship', + relationTo: 'posts', + }, + ], + }, + ], + }, ], }, ], diff --git a/test/live-preview/int.spec.ts b/test/live-preview/int.spec.ts index c432da5af..7d521f3f7 100644 --- a/test/live-preview/int.spec.ts +++ b/test/live-preview/int.spec.ts @@ -307,6 +307,27 @@ describe('Collections - Live Preview', () => { expect(merge2.relationshipPolyHasMany).toEqual([]) }) + it('— relationships - populates within tabs', async () => { + const initialData: Partial = { + title: 'Test Page', + } + + const merge1 = await mergeData({ + depth: 1, + fieldSchema: schemaJSON, + incomingData: { + ...initialData, + tab: { + relationshipInTab: testPost.id, + }, + }, + initialData, + serverURL, + }) + + expect(merge1.tab.relationshipInTab).toMatchObject(testPost) + }) + it('— relationships - populates within arrays', async () => { const initialData: Partial = { title: 'Test Page', diff --git a/test/live-preview/payload-types.ts b/test/live-preview/payload-types.ts index 14c54a5b6..3b23ba0ab 100644 --- a/test/live-preview/payload-types.ts +++ b/test/live-preview/payload-types.ts @@ -152,11 +152,6 @@ export interface Page { } )[] | null - meta?: { - title?: string | null - description?: string | null - image?: string | Media | null - } relationshipInRichText?: | { [k: string]: unknown @@ -198,6 +193,14 @@ export interface Page { id?: string | null }[] | null + tab: { + relationshipInTab?: (string | null) | Post + } + meta?: { + title?: string | null + description?: string | null + image?: string | Media | null + } updatedAt: string createdAt: string }