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

[BUG]: Component relations inside dynamic zone disappear when translating from content manager #315

Open
gaspop opened this issue Sep 22, 2023 · 3 comments
Milestone

Comments

@gaspop
Copy link

gaspop commented Sep 22, 2023

Describe the bug
If a collection/single type has a dynamic zone, and a component inside that zone has a relation to another collection type/entity, this relation is reset when using "translate from another locale" inside the content manager and saving.

To Reproduce
Steps to reproduce the behavior:

  1. In the content-type builder, Create a collection type called "Type A"
  2. Create a component called "Block", with a field relation to "Type A"
  3. Create another collection type called "Type B" with a dynamic zone, where you can add the "Block" component.
  4. In settings, under internationalization, add a second locale if there isn't one
  5. In the content manager, create an instance of "Type A", translate this instance to another locale.
  6. Create an instance of Type B, add a "Block" component to its dynamic zone and set the relation to the instance of "Type A"
  7. Open the new instance of Type B in the second locale, then press "Translate from another locale" and select the first locale.
  8. Before saving, look at the component inside the dynamic zone, it should show a relation to the translated instance of "Type A".
  9. Save, leave the translated instance and return, look at the component inside the dynamic zone again. The relation is gone.

Expected behavior
When pressing save after selecting "translate from another locale", relations in components in dynamic zones should not be lost.

Screenshots
N/A

System (please complete the following information):

Plugin config
Please add your plugin config here, e.g.

module.exports = {
  translate: {
    enabled: true,
    config: {
      provider: 'deepl',
    },
  },
}

Additional context
It looks as if the relation is still there after translating, but it isn't kept when saving. The problem only occurs when translating in the content manager, not when batch translating.

@bkrajewski94
Copy link

Hi :) I have exactly the same issue.

I also discovered that:

  • when you retranslate a page, relations in a dynamic zone are still visible in the UI, and they are properly included in the translate request http response
  • it breaks when you save changes. Each relation in dynamic zone has following set in the save request payload:
dynamicZoneName: [
    0: {
        foo: {bar: {disconnect: [], connect: []}}
    }
]
  • you don't see it break on UI immediately. You get save request response, you still see the relations on the UI, you think everything is fine, but then when you refresh, you see that the relations are gone...
  • if you now retranslate (after relations were removed and are now empty), and then save again, they are re-added. This time the save request payload has
dynamicZoneName: [
    0: {
        foo: {bar: {disconnect: [], connect: [{id: 2, position: {end: true}}]}}
    }
]

I see no difference with translate request payload / response between when it works and when it fails. The only difference is in the save request

@sargreal
Copy link
Member

sargreal commented Dec 2, 2024

@gaspop Thank you first of all for opening this issue and sorry for the long delay in answering.

I cannot reproduce this issue with the latest version of strapi-plugin-translate 1.2.6 anymore, can you please check if you still experience this issue?
And if yes, can you please share minimal content-types and components where you experience this issue?

@bkrajewski94 I am also unable to reproduce your retranslation issue. Can you please share minimal content-types and components where you experience this issue as well?

@bkrajewski94
Copy link

Hi @sargreal - thanks for your answer :) I've just bootstrapped a demo strapi project based on v1.2.6, and I confirm the problem is gone! Great work

However, when I try to upgrade to v1.2.6 in the commercial project I'm working on, I see an error. See here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Investigate
Development

No branches or pull requests

3 participants