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

SimpleShowLayout does not pass resource to Labeled Component, translation fails #9965

Closed
glauff opened this issue Jun 28, 2024 · 3 comments · Fixed by #9966
Closed

SimpleShowLayout does not pass resource to Labeled Component, translation fails #9965

glauff opened this issue Jun 28, 2024 · 3 comments · Fixed by #9966
Assignees
Labels

Comments

@glauff
Copy link

glauff commented Jun 28, 2024

What you were expecting:
When nesting Field Components into a SimpleShowLayout the Label should be correctly translated.
What happened instead:
After migration to react-admin v5 the Fields in a SimpleShow Layout have not the correct translation
Steps to reproduce:
Just nest Fields into a SimpleShowLayout with a translation of fields to a resource in place
Related code:

SimpleShowLayout is not passing resource to Labeled
https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/detail/SimpleShowLayout.tsx
Labeled ist only using the passed resource prop and not also the ResourceContext
https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/Labeled.tsx

Environment

  • React-admin version: 5.0.2
  • Last version that did not exhibit the issue (if applicable): 4.x.x
  • React version: 18
  • Browser: Chrome
@fzaninotto
Copy link
Member

I'm not sure what you mean by "nesting fields". Can you please add a reproduction based on the simple example StackBlitz?

https://stackblitz.com/github/marmelab/react-admin/tree/master/examples/simple?file=README.md

@glauff
Copy link
Author

glauff commented Jun 28, 2024

Sure, here you go
https://stackblitz.com/edit/github-wuzwwv

I've modified the posts list to display the PostShow View on rowClick

PostShowView now contains just a SimpleShowLayout with a TextField with a source prop set to "notifications"

The translation for "notifications" in "en" is "Notifications recipients", but only "Notifications" is shown because resource context is missing

Hope this clarifies my issue.

@fzaninotto
Copy link
Member

Thanks for the repro. I can confirm the bug.

According to my initial analysis, it doesn't come from a Resource Context problem, but from a logic problem in useTranslateLabel or getFieldTranslationArgs.

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.

2 participants