Open stefvw93 opened 8 months ago
Hey
Any news on the solution for this problem ?
I've found a workaround for this. Just set relationTo
to an array, even if you only need to reference a single collection, like relationTo: ['images']
instead of relationTo: 'images'
.
In this way the resulting field values will have the form of { relationTo: <collection-slug>, value: <resolved-document> }
, which is resolved correctly by traverseRichText
.
Link to reproduction
No response
Describe the Bug
The following line in the rich text traverser detects relations based on the
relationTo
andvalue
fields inside any given iterated object in a rich text tree: https://github.com/payloadcms/payload/blob/c038acb3a4da6cda85d034aeb8b042d172ee868f/packages/live-preview/src/traverseRichText.ts#L59However, 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
type: 'relation'
field, with arelationTo
some other collection.depth
> 0callback
function<fieldname>: <id>
entry, regardless of thedepth
parameter.Payload Version
2.11.2
Adapters and Plugins
@payloadcms/live-preview@0.2.0