Skip to content

Reordering Relations in Dynamic Zone cause blank screen #14908

@kevinlaihk01

Description

@kevinlaihk01

Bug report

Required System information

  • Node.js version: 16.17.0
  • NPM version: 8.15.0
  • Strapi version: 4.5.0
  • Database: mysql v8
  • Operating system: macOs 12.5

Describe the bug

When a Relation component is used in a Dynamic Zone, reordering the Relation component will lead to a blank screen with following error:

TypeError: i is not iterable

Steps to reproduce the behavior

  1. create Relation component
  2. create a Dynamic Zone which use that Relation component, and also any other component type
  3. in Content Manager, reorder the added Relation component among other components in the same Dynamic Zone

Expected behavior

Reordering a Relation component in Dynamic Zone won't lead to a blank screen

Screenshots

Screenshot 2022-11-17 at 4 25 30 PM

Code snippets

suggest to change this line —

set(draftState, initialDataPath, uniqBy([...value, ...initialDataRelations], 'id'));

from

        set(draftState, initialDataPath, uniqBy([...value, ...initialDataRelations], 'id'));
        set(draftState, initialDataPath, uniqBy([...value, ...(initialDataRelations || [])], 'id'));

So it wont spreading an undefined initialDataRelations (which its index in dynamic zone is changed) when reordering the Relation component

Metadata

Metadata

Assignees

Labels

issue: bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundsource: core:content-managerSource is core/content-manager packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions