fix(ui): error in version view if document contains localized arrays or blocks (#10893)

Fixes https://github.com/payloadcms/payload/issues/10884
This commit is contained in:
Alessio Gravili
2025-01-30 12:45:47 -07:00
committed by GitHub
parent 2b9ee62fc0
commit 85c0842444
6 changed files with 63 additions and 12 deletions

View File

@@ -15,6 +15,17 @@ export const Diff: CollectionConfig = {
},
],
},
{
name: 'arrayLocalized',
type: 'array',
localized: true,
fields: [
{
name: 'textInArrayLocalized',
type: 'text',
},
],
},
{
name: 'blocks',
type: 'blocks',

View File

@@ -945,6 +945,21 @@ describe('Versions', () => {
await expect(textInArray.locator('tr').nth(1).locator('td').nth(3)).toHaveText('textInArray2')
})
test('correctly renders diff for localized array fields', async () => {
await navigateToVersionFieldsDiff()
const textInArray = page
.locator('[data-field-path="arrayLocalized"][data-locale="en"]')
.locator('[data-field-path="arrayLocalized.0.textInArrayLocalized"]')
await expect(textInArray.locator('tr').nth(1).locator('td').nth(1)).toHaveText(
'textInArrayLocalized',
)
await expect(textInArray.locator('tr').nth(1).locator('td').nth(3)).toHaveText(
'textInArrayLocalized2',
)
})
test('correctly renders diff for block fields', async () => {
await navigateToVersionFieldsDiff()

View File

@@ -224,6 +224,12 @@ export interface Diff {
id?: string | null;
}[]
| null;
arrayLocalized?:
| {
textInArrayLocalized?: string | null;
id?: string | null;
}[]
| null;
blocks?:
| {
textInBlock?: string | null;
@@ -641,6 +647,12 @@ export interface DiffSelect<T extends boolean = true> {
textInArray?: T;
id?: T;
};
arrayLocalized?:
| T
| {
textInArrayLocalized?: T;
id?: T;
};
blocks?:
| T
| {

View File

@@ -122,12 +122,18 @@ export async function seed(_payload: Payload, parallel: boolean = false) {
const diffDoc = await _payload.create({
collection: diffCollectionSlug,
locale: 'en',
data: {
array: [
{
textInArray: 'textInArray',
},
],
arrayLocalized: [
{
textInArrayLocalized: 'textInArrayLocalized',
},
],
blocks: [
{
blockType: 'TextBlock',
@@ -164,12 +170,18 @@ export async function seed(_payload: Payload, parallel: boolean = false) {
const updatedDiffDoc = await _payload.update({
id: diffDoc.id,
collection: diffCollectionSlug,
locale: 'en',
data: {
array: [
{
textInArray: 'textInArray2',
},
],
arrayLocalized: [
{
textInArrayLocalized: 'textInArrayLocalized2',
},
],
blocks: [
{
blockType: 'TextBlock',