diff --git a/packages/drizzle/src/utilities/hasLocalesTable.ts b/packages/drizzle/src/utilities/hasLocalesTable.ts index 949414fa6d..3a2a3899d5 100644 --- a/packages/drizzle/src/utilities/hasLocalesTable.ts +++ b/packages/drizzle/src/utilities/hasLocalesTable.ts @@ -4,8 +4,10 @@ import { fieldAffectsData, fieldHasSubFields } from 'payload/shared' export const hasLocalesTable = (fields: Field[]): boolean => { return fields.some((field) => { + // arrays always get a separate table + if (field.type === 'array') return false if (fieldAffectsData(field) && field.localized) return true - if (fieldHasSubFields(field) && field.type !== 'array') return hasLocalesTable(field.fields) + if (fieldHasSubFields(field)) return hasLocalesTable(field.fields) if (field.type === 'tabs') return field.tabs.some((tab) => hasLocalesTable(tab.fields)) return false }) diff --git a/test/fields/collections/Blocks/index.ts b/test/fields/collections/Blocks/index.ts index 82694c88e0..5be2417dc3 100644 --- a/test/fields/collections/Blocks/index.ts +++ b/test/fields/collections/Blocks/index.ts @@ -184,6 +184,28 @@ const BlockFields: CollectionConfig = { }, }, }, + { + name: 'blocksWithLocalizedArray', + type: 'blocks', + blocks: [ + { + slug: 'localizedArray', + fields: [ + { + name: 'array', + type: 'array', + localized: true, + fields: [ + { + name: 'text', + type: 'text', + }, + ], + }, + ], + }, + ], + }, { name: 'blocksWithSimilarConfigs', type: 'blocks', diff --git a/test/fields/int.spec.ts b/test/fields/int.spec.ts index 1de61d01ee..c4371ecd79 100644 --- a/test/fields/int.spec.ts +++ b/test/fields/int.spec.ts @@ -1278,6 +1278,26 @@ describe('Fields', () => { expect(equalsMissResult).toBeUndefined() expect(inMissResult).toBeUndefined() }) + + it('should allow localized array of blocks', async () => { + const result = await payload.create({ + collection: blockFieldsSlug, + data: { + blocksWithLocalizedArray: [ + { + blockType: 'localizedArray', + array: [ + { + text: 'localized', + }, + ], + }, + ], + }, + }) + + expect(result.blocksWithLocalizedArray[0].array[0].text).toEqual('localized') + }) }) describe('json', () => {