fix(drizzle): row / collapsible inside of localized fields (#8539)

Fixes https://github.com/payloadcms/payload/issues/8405
This commit is contained in:
Sasha
2024-10-04 18:48:54 +03:00
committed by GitHub
parent f6eb027f23
commit 414030e1f1
4 changed files with 58 additions and 1 deletions

View File

@@ -363,6 +363,7 @@ export const traverseFields = ({
existingLocales,
fieldPrefix,
fields: field.fields,
forcedLocale,
locales,
numbers,
parentTableName,

View File

@@ -1,10 +1,26 @@
import type { CollectionConfig } from 'payload/types'
import type { CollectionConfig } from 'payload'
export const groupSlug = 'groups'
export const Group: CollectionConfig = {
slug: groupSlug,
fields: [
{
name: 'groupLocalizedRow',
type: 'group',
localized: true,
fields: [
{
type: 'row',
fields: [
{
name: 'text',
type: 'text',
},
],
},
],
},
{
name: 'groupLocalized',
type: 'group',
@@ -16,6 +32,7 @@ export const Group: CollectionConfig = {
],
localized: true,
},
{
name: 'group',
type: 'group',

View File

@@ -1452,6 +1452,42 @@ describe('Localization', () => {
expect(docEs.deep.blocks[0].title).toBe('hello es')
})
it('should create/updated/read localized group with row field', async () => {
const doc = await payload.create({
collection: 'groups',
data: {
groupLocalizedRow: {
text: 'hello world',
},
},
locale: 'en',
})
expect(doc.groupLocalizedRow.text).toBe('hello world')
const docES = await payload.update({
collection: 'groups',
data: {
groupLocalizedRow: {
text: 'hola world or something',
},
},
locale: 'es',
id: doc.id,
})
expect(docES.groupLocalizedRow.text).toBe('hola world or something')
// check if docES didnt break EN
const docEN = await payload.findByID({ collection: 'groups', id: doc.id, locale: 'en' })
expect(docEN.groupLocalizedRow.text).toBe('hello world')
const all = await payload.findByID({ collection: 'groups', id: doc.id, locale: 'all' })
expect(all.groupLocalizedRow.en.text).toBe('hello world')
expect(all.groupLocalizedRow.es.text).toBe('hola world or something')
})
it('should properly create/update/read localized tab field', async () => {
const result = await payload.create({
collection: tabSlug,

View File

@@ -402,6 +402,9 @@ export interface Group {
groupLocalized?: {
title?: string | null;
};
groupLocalizedRow?: {
text?: string | null;
};
group?: {
title?: string | null;
};