Skip to content

Commit 477a7f2

Browse files
authored
Merge pull request #10125 from glauff/master
Fix <TranslatableInputs> throws error when used with null value
2 parents 169f5f8 + 639a0e5 commit 477a7f2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/ra-core/src/i18n/useTranslatable.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ describe('useTranslatable', () => {
55
// Given the record { title: { en: 'title_en', fr: 'title_fr' } } and the locale 'fr',
66
// the record for the locale 'fr' will be { title: 'title_fr' }
77
const record = {
8+
nullEntry: null,
89
fractal: true,
910
title: { en: 'title_en', fr: 'title_fr' },
1011
items: [
@@ -16,6 +17,7 @@ describe('useTranslatable', () => {
1617
const recordForLocale = getRecordForLocale(record, 'fr');
1718

1819
expect(recordForLocale).toEqual({
20+
nullEntry: null,
1921
fractal: true,
2022
title: 'title_fr',
2123
items: [

packages/ra-core/src/i18n/useTranslatable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const getRecordPaths = (
101101
path: Array<string> = []
102102
): Array<Array<string>> => {
103103
return Object.entries(record).reduce((acc, [key, value]) => {
104-
if (typeof value === 'object') {
104+
if (value !== null && typeof value === 'object') {
105105
return [
106106
...acc,
107107
[...path, key],

0 commit comments

Comments
 (0)