Skip to content

Live preview does not correctly find relations when using blocks inside the lexical rte. #5285

Open
@stefvw93

Description

@stefvw93

Link to reproduction

No response

Describe the Bug

The following line in the rich text traverser detects relations based on the relationTo and value fields inside any given iterated object in a rich text tree:

const isRelationship = key === 'value' && 'relationTo' in incomingData

However, when using the blocks feature in the lexical rte, relationships are not defined by those fields, and instead simply hold an id string reference field.

Because of this, the rich text traverser is never able to resolve relation fields inside blocks.

To Reproduce

  1. Enable lexical editor field on some collection.
  2. Use the Blocks feature
  3. Create a block with a type: 'relation' field, with a relationTo some other collection.
  4. Populate the field in the admin UI
  5. Implement the live preview feature, set depth > 0
  6. Check the data returned from the callback function
  7. The relation field in the respective block will always just havr a <fieldname>: <id> entry, regardless of the depth parameter.

Payload Version

2.11.2

Adapters and Plugins

@payloadcms/[email protected]

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions