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

Duplicating resources does not populate relation inputs #15093

Closed
samturrell opened this issue Dec 6, 2022 · 9 comments · Fixed by #16192
Closed

Duplicating resources does not populate relation inputs #15093

samturrell opened this issue Dec 6, 2022 · 9 comments · Fixed by #16192
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:content-manager Source is core/content-manager package status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@samturrell
Copy link

Bug report

Required System information

  • Node.js version: v14.19.3
  • NPM version: 6.14.17
  • Strapi version: 4.5.3
  • Database: mysql
  • Operating system: macOS

Describe the bug

When duplicating a page, relation inputs aren't populated.

Steps to reproduce the behavior

  1. Create a resource with a linked relation
  2. Go to the collection listing page
  3. Click to duplicate an item
  4. Observe that the relations are not pulled through

See the recording below:

https://www.loom.com/share/816a4bb8b0db4d3a8c242c6ac5e07969

Expected behavior

Relations should be pulled through from the resource being duplicated.

Screenshots

https://www.loom.com/share/816a4bb8b0db4d3a8c242c6ac5e07969

Code snippets

N/A

Additional context

N/A

@gu-stav gu-stav added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around status: confirmed Confirmed by a Strapi Team member or multiple community members source: core:content-manager Source is core/content-manager package labels Dec 7, 2022
@petersg83
Copy link
Contributor

Indeed there is a regression here.

The way it was working before was that : when clicking on the duplicate button it was only opening the edit view with the form pre-filled (including relations). As we don’t load all relations anymore in the front because of performance issues, we need to rethink the duplicate feature and the user’s path to achieve a full duplicate.
Loading all the relations to fix this issue would just re-create the performance issues (not able to save when there are more than 1000 relations of instance etc.), so it would not be the way to go.

@joshuaellis
Copy link
Member

@petersg83 i've wondered this for a while actually, how come we clone browser side? And not server-side? If we were to do it server-side, this would probably remove this issue?

@petersg83
Copy link
Contributor

petersg83 commented Dec 8, 2022

There are several reasons :

  • so the user can edit it before
  • because the duplicate action can be destructive on relations, like a x-to-one relation. It would remove the relation from the original entry. So it's best if the user can edit it before saving, it becomes their responsibility.

Side note :

  • I wonder what happens with i18n

@gu-stav
Copy link
Contributor

gu-stav commented Dec 12, 2022

We have discussed this issue today and will work on fixing this, but it will take a bit longer because the current way of cloning is broken with the refactoring of relations. We agreed that we need to explore how we will handle cloning in the future and keep you posted.

@JulienHe
Copy link

I don't know if that's related, but when you Fill in from another locale the issue is similar, even worst the relations from the original page are going away.

@gu-stav
Copy link
Contributor

gu-stav commented Dec 16, 2022

Hello 👋🏼 We have discussed this issue recently because there is no easy solution to it at the moment. We have simply forgotten about this case when we started the refactoring work on relations.

Right now the frontend doesn't know longer about the relations that might exist in the cloned entity (which is a necessary performance optimization). This means we would have address cloning differently and may have to move it to the backend (to be decided).

I don't know if that's related, but when you Fill in from another locale the issue is similar, even worst the relations from the original page are going away.

This is a different issue, @JulienHe. Relational fields are always localized and there is no way currently to inherit relations from a different locale, so this is by design. You can e.g. subscribe + upvote this feature request: https://feedback.strapi.io/feature-requests/p/keep-relations-when-switching-between-locales

@derrickmehaffy
Copy link
Member

I'll go ahead and close this issue since it's more so a feature request as Gustav pointed out

@gu-stav
Copy link
Contributor

gu-stav commented Jan 2, 2023

@derrickmehaffy I'd like to reopen this issue if you don't mind because the comments above mix two issues:

  • we will work on duplicating an entity from the CM list view, because this is simply broken for now, but the solution is not easy
  • we won't work on relational fields when filling from another locale, because this part works as intended (relations are always localized) for now

@gu-stav gu-stav reopened this Jan 2, 2023
@derrickmehaffy
Copy link
Member

@derrickmehaffy I'd like to reopen this issue if you don't mind because the comments above mix two issues:

  • we will work on duplicating an entity from the CM list view, because this is simply broken for now, but the solution is not easy
  • we won't work on relational fields when filling from another locale, because this part works as intended (relations are always localized) for now

Can you update the title?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:content-manager Source is core/content-manager package status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
Status: Fixed/Shipped
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants