fix(drizzle): row / collapsible inside of localized fields (#8539)
Fixes https://github.com/payloadcms/payload/issues/8405
This commit is contained in:
@@ -363,6 +363,7 @@ export const traverseFields = ({
|
|||||||
existingLocales,
|
existingLocales,
|
||||||
fieldPrefix,
|
fieldPrefix,
|
||||||
fields: field.fields,
|
fields: field.fields,
|
||||||
|
forcedLocale,
|
||||||
locales,
|
locales,
|
||||||
numbers,
|
numbers,
|
||||||
parentTableName,
|
parentTableName,
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
import type { CollectionConfig } from 'payload/types'
|
import type { CollectionConfig } from 'payload'
|
||||||
|
|
||||||
export const groupSlug = 'groups'
|
export const groupSlug = 'groups'
|
||||||
|
|
||||||
export const Group: CollectionConfig = {
|
export const Group: CollectionConfig = {
|
||||||
slug: groupSlug,
|
slug: groupSlug,
|
||||||
fields: [
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'groupLocalizedRow',
|
||||||
|
type: 'group',
|
||||||
|
localized: true,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'row',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'text',
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'groupLocalized',
|
name: 'groupLocalized',
|
||||||
type: 'group',
|
type: 'group',
|
||||||
@@ -16,6 +32,7 @@ export const Group: CollectionConfig = {
|
|||||||
],
|
],
|
||||||
localized: true,
|
localized: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'group',
|
name: 'group',
|
||||||
type: 'group',
|
type: 'group',
|
||||||
|
|||||||
@@ -1452,6 +1452,42 @@ describe('Localization', () => {
|
|||||||
expect(docEs.deep.blocks[0].title).toBe('hello es')
|
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 () => {
|
it('should properly create/update/read localized tab field', async () => {
|
||||||
const result = await payload.create({
|
const result = await payload.create({
|
||||||
collection: tabSlug,
|
collection: tabSlug,
|
||||||
|
|||||||
@@ -402,6 +402,9 @@ export interface Group {
|
|||||||
groupLocalized?: {
|
groupLocalized?: {
|
||||||
title?: string | null;
|
title?: string | null;
|
||||||
};
|
};
|
||||||
|
groupLocalizedRow?: {
|
||||||
|
text?: string | null;
|
||||||
|
};
|
||||||
group?: {
|
group?: {
|
||||||
title?: string | null;
|
title?: string | null;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user