Skip to content

Commit 414030e

Browse files
authored
fix(drizzle): row / collapsible inside of localized fields (#8539)
Fixes #8405
1 parent f6eb027 commit 414030e

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

packages/drizzle/src/transform/write/traverseFields.ts

+1
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ export const traverseFields = ({
363363
existingLocales,
364364
fieldPrefix,
365365
fields: field.fields,
366+
forcedLocale,
366367
locales,
367368
numbers,
368369
parentTableName,

test/localization/collections/Group/index.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
import type { CollectionConfig } from 'payload/types'
1+
import type { CollectionConfig } from 'payload'
22

33
export const groupSlug = 'groups'
44

55
export const Group: CollectionConfig = {
66
slug: groupSlug,
77
fields: [
8+
{
9+
name: 'groupLocalizedRow',
10+
type: 'group',
11+
localized: true,
12+
fields: [
13+
{
14+
type: 'row',
15+
fields: [
16+
{
17+
name: 'text',
18+
type: 'text',
19+
},
20+
],
21+
},
22+
],
23+
},
824
{
925
name: 'groupLocalized',
1026
type: 'group',
@@ -16,6 +32,7 @@ export const Group: CollectionConfig = {
1632
],
1733
localized: true,
1834
},
35+
1936
{
2037
name: 'group',
2138
type: 'group',

test/localization/int.spec.ts

+36
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,42 @@ describe('Localization', () => {
14521452
expect(docEs.deep.blocks[0].title).toBe('hello es')
14531453
})
14541454

1455+
it('should create/updated/read localized group with row field', async () => {
1456+
const doc = await payload.create({
1457+
collection: 'groups',
1458+
data: {
1459+
groupLocalizedRow: {
1460+
text: 'hello world',
1461+
},
1462+
},
1463+
locale: 'en',
1464+
})
1465+
1466+
expect(doc.groupLocalizedRow.text).toBe('hello world')
1467+
1468+
const docES = await payload.update({
1469+
collection: 'groups',
1470+
data: {
1471+
groupLocalizedRow: {
1472+
text: 'hola world or something',
1473+
},
1474+
},
1475+
locale: 'es',
1476+
id: doc.id,
1477+
})
1478+
1479+
expect(docES.groupLocalizedRow.text).toBe('hola world or something')
1480+
1481+
// check if docES didnt break EN
1482+
const docEN = await payload.findByID({ collection: 'groups', id: doc.id, locale: 'en' })
1483+
expect(docEN.groupLocalizedRow.text).toBe('hello world')
1484+
1485+
const all = await payload.findByID({ collection: 'groups', id: doc.id, locale: 'all' })
1486+
1487+
expect(all.groupLocalizedRow.en.text).toBe('hello world')
1488+
expect(all.groupLocalizedRow.es.text).toBe('hola world or something')
1489+
})
1490+
14551491
it('should properly create/update/read localized tab field', async () => {
14561492
const result = await payload.create({
14571493
collection: tabSlug,

test/localization/payload-types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ export interface Group {
402402
groupLocalized?: {
403403
title?: string | null;
404404
};
405+
groupLocalizedRow?: {
406+
text?: string | null;
407+
};
405408
group?: {
406409
title?: string | null;
407410
};

0 commit comments

Comments
 (0)