Skip to content

Commit

Permalink
Merge pull request #10125 from glauff/master
Browse files Browse the repository at this point in the history
Fix <TranslatableInputs> throws error when used with null value
  • Loading branch information
djhi authored Aug 2, 2024
2 parents 169f5f8 + 639a0e5 commit 477a7f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/ra-core/src/i18n/useTranslatable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -16,6 +17,7 @@ describe('useTranslatable', () => {
const recordForLocale = getRecordForLocale(record, 'fr');

expect(recordForLocale).toEqual({
nullEntry: null,
fractal: true,
title: 'title_fr',
items: [
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/i18n/useTranslatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const getRecordPaths = (
path: Array<string> = []
): Array<Array<string>> => {
return Object.entries(record).reduce((acc, [key, value]) => {
if (typeof value === 'object') {
if (value !== null && typeof value === 'object') {
return [
...acc,
[...path, key],
Expand Down

0 comments on commit 477a7f2

Please sign in to comment.