Skip to content

Commit

Permalink
fix(drizzle): row / collapsible inside of localized fields (#8539)
Browse files Browse the repository at this point in the history
Fixes #8405
  • Loading branch information
r1tsuu authored Oct 4, 2024
1 parent f6eb027 commit 414030e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/drizzle/src/transform/write/traverseFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export const traverseFields = ({
existingLocales,
fieldPrefix,
fields: field.fields,
forcedLocale,
locales,
numbers,
parentTableName,
Expand Down
19 changes: 18 additions & 1 deletion test/localization/collections/Group/index.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -16,6 +32,7 @@ export const Group: CollectionConfig = {
],
localized: true,
},

{
name: 'group',
type: 'group',
Expand Down
36 changes: 36 additions & 0 deletions test/localization/int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions test/localization/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ export interface Group {
groupLocalized?: {
title?: string | null;
};
groupLocalizedRow?: {
text?: string | null;
};
group?: {
title?: string | null;
};
Expand Down

0 comments on commit 414030e

Please sign in to comment.