Skip to content

Commit 09721d4

Browse files
authored
fix(next): viewing modified-only diff view containing localized arrays throws error (#11006)
Fixes #11002 `buildVersionFields` was adding `null` version fields to the version fields array. When RenderVersionFieldsToDiff tried to render those, it threw an error. This PR ensures no `null` fields are added, as `RenderVersionFieldsToDiff` can't process them. That way, those fields are properly skipped, which is the intent of `modifiedOnly`
1 parent 834fdde commit 09721d4

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

packages/next/src/views/Version/RenderFieldsToDiff/buildVersionFields.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const buildVersionFields = ({
113113
versionField.fieldByLocale = {}
114114

115115
for (const locale of selectedLocales) {
116-
versionField.fieldByLocale[locale] = buildVersionField({
116+
const localizedVersionField = buildVersionField({
117117
clientField: clientField as ClientField,
118118
clientSchemaMap,
119119
comparisonValue: comparisonValue?.[locale],
@@ -133,12 +133,12 @@ export const buildVersionFields = ({
133133
selectedLocales,
134134
versionValue: versionValue?.[locale],
135135
})
136-
if (!versionField.fieldByLocale[locale]) {
137-
continue
136+
if (localizedVersionField) {
137+
versionField.fieldByLocale[locale] = localizedVersionField
138138
}
139139
}
140140
} else {
141-
versionField.field = buildVersionField({
141+
const baseVersionField = buildVersionField({
142142
clientField: clientField as ClientField,
143143
clientSchemaMap,
144144
comparisonValue,
@@ -158,8 +158,8 @@ export const buildVersionFields = ({
158158
versionValue,
159159
})
160160

161-
if (!versionField.field) {
162-
continue
161+
if (baseVersionField) {
162+
versionField.field = baseVersionField
163163
}
164164
}
165165

test/versions/e2e.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,18 @@ describe('Versions', () => {
960960
)
961961
})
962962

963+
test('correctly renders modified-only diff for localized array fields', async () => {
964+
await navigateToVersionFieldsDiff()
965+
966+
const textInArrayES = page.locator('[data-field-path="arrayLocalized"][data-locale="es"]')
967+
968+
await expect(textInArrayES).toContainText('No Array Localizeds found')
969+
970+
await page.locator('#modifiedOnly').click()
971+
972+
await expect(textInArrayES).toBeHidden()
973+
})
974+
963975
test('correctly renders diff for block fields', async () => {
964976
await navigateToVersionFieldsDiff()
965977

0 commit comments

Comments
 (0)