From 639a0e5e21979c90c45e52e32a8ea721bb011abb Mon Sep 17 00:00:00 2001 From: Gaetan Lauff Date: Fri, 2 Aug 2024 09:53:58 +0200 Subject: [PATCH] fix #10107 --- packages/ra-core/src/i18n/useTranslatable.spec.ts | 2 ++ packages/ra-core/src/i18n/useTranslatable.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ra-core/src/i18n/useTranslatable.spec.ts b/packages/ra-core/src/i18n/useTranslatable.spec.ts index 78483c463a2..3504177f57f 100644 --- a/packages/ra-core/src/i18n/useTranslatable.spec.ts +++ b/packages/ra-core/src/i18n/useTranslatable.spec.ts @@ -5,6 +5,7 @@ describe('useTranslatable', () => { // Given the record { title: { en: 'title_en', fr: 'title_fr' } } and the locale 'fr', // the record for the locale 'fr' will be { title: 'title_fr' } const record = { + nullEntry: null, fractal: true, title: { en: 'title_en', fr: 'title_fr' }, items: [ @@ -16,6 +17,7 @@ describe('useTranslatable', () => { const recordForLocale = getRecordForLocale(record, 'fr'); expect(recordForLocale).toEqual({ + nullEntry: null, fractal: true, title: 'title_fr', items: [ diff --git a/packages/ra-core/src/i18n/useTranslatable.ts b/packages/ra-core/src/i18n/useTranslatable.ts index cee8e9fc12b..9b6725b823e 100644 --- a/packages/ra-core/src/i18n/useTranslatable.ts +++ b/packages/ra-core/src/i18n/useTranslatable.ts @@ -101,7 +101,7 @@ const getRecordPaths = ( path: Array = [] ): Array> => { return Object.entries(record).reduce((acc, [key, value]) => { - if (typeof value === 'object') { + if (value !== null && typeof value === 'object') { return [ ...acc, [...path, key],