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

Choices are translated even when SelectInput is a child of ReferenceInput #9134

Closed
fzaninotto opened this issue Jul 25, 2023 · 0 comments · Fixed by #9176
Closed

Choices are translated even when SelectInput is a child of ReferenceInput #9134

fzaninotto opened this issue Jul 25, 2023 · 0 comments · Fixed by #9176
Assignees
Labels

Comments

@fzaninotto
Copy link
Member

What you were expecting:

Choices that are fetched from a reference (e.g. authors from a book) shouldn't be translated.

What happened instead:

They are translated, but as they use their value as default translation, this isn't visible unless you enable the missing translation warnings in the i18nProvider.

Steps to reproduce:

  1. Open this Stackblitz, which is a fork of the simple example: https://stackblitz.com/edit/github-qm3anf
  2. Go to the comment list
  3. Click on the first comment to open the comment edition page
  4. Click on the post dropdown to reveal the list of options
  5. The fist option is 'ERROR'
image

The only modifications I made relative to the canonical simple example are:

  1. Replace AutocompleteInput by SelectInput in the CommentEdit form
  2. Add a translation for the string 'A voluptas eius eveniet ut commodi dolor' in the English messages

Related code:

This has to do with the translateChoices prop in choice inputs (SelectInput, AutocompleteInput, RadioButtonGrupoInput, CheckboxGrupInput, etc.). Its default value should be true, except when inside a Reference input.

This feature used to work in v3, when ReferenceInput cloned its child.

It no longer works in v4, despite what's documented:

Note that translateChoice is set to false when <SelectInput> is a child of <ReferenceInput>.

Environment

  • React-admin version: v4
  • Last version that did not exhibit the issue (if applicable): v3
  • React version: 17
  • Browser: All
@fzaninotto fzaninotto added the bug label Jul 25, 2023
@fzaninotto fzaninotto changed the title translateChoices is not false when a SelectInput is a child of ReferenceInput Choices are translated even when SelectInput is a child of ReferenceInput Jul 25, 2023
@fzaninotto fzaninotto self-assigned this Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant