Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix <TranslatableInputs> throws error when used with null value #10125

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading