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] Relation path setup #15254

Merged
merged 1 commit into from
Dec 27, 2022
Merged

[fix] Relation path setup #15254

merged 1 commit into from
Dec 27, 2022

Conversation

ronronscelestes
Copy link
Contributor

@ronronscelestes ronronscelestes commented Dec 22, 2022

What

fixes #14968

When a path to relations included direct duplicate keys as

['units', 'units', 'units']

findLeafAndReplace would replace the first leaf instead of making sure it is the last item in the array of paths - as recommended in the comment:

If this is the last item in the array of paths

e.g. for a relation inside a repeatable component, it would cause the repeatable component to not be renderer as the state would reflect

units: []

instead of

units: {
  units: [{
    units: []
  }]
}

Test

I think this fix needs a thorough QA with relations in:

  • components
  • repeatable components
  • dynamic zones

example:

CTB:

  • create a Unit content-type with a text field named name
  • create a component Test with a relation field to Unit and name this relation field units
  • create a Module content-type with Test as repeatable component and name this field units

CM:

  • create some Unit entries
  • create a Module entry and populate the repeatable component
  • the repeatable component field units should render on save and on reload

Shoutout

with @petersg83 huge help 👑

@ronronscelestes ronronscelestes added source: core:content-manager Source is core/content-manager package pr: fix This PR is fixing a bug labels Dec 22, 2022
@codecov
Copy link

codecov bot commented Dec 22, 2022

Codecov Report

Base: 60.49% // Head: 60.49% // No change to project coverage 👍

Coverage data is based on head (e5e2018) compared to base (05be584).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15254   +/-   ##
=======================================
  Coverage   60.49%   60.49%           
=======================================
  Files        1352     1352           
  Lines       33174    33174           
  Branches     6337     6337           
=======================================
  Hits        20070    20070           
  Misses      11271    11271           
  Partials     1833     1833           
Flag Coverage Δ
back 50.35% <ø> (ø)
front 65.05% <100.00%> (ø)
unit_back 50.35% <ø> (ø)
unit_front 65.05% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...aManagerProvider/utils/findLeafByPathAndReplace.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@gu-stav gu-stav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works for me - well done! 👏🏼

@ronronscelestes ronronscelestes merged commit b76c413 into main Dec 27, 2022
@ronronscelestes ronronscelestes deleted the fix/relational-path branch December 27, 2022 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix This PR is fixing a bug source: core:content-manager Source is core/content-manager package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with dynamic zone.
2 participants