-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Closed
Copy link
Labels
Description
Describe the Bug
When using the built in lexical LinkFeature with more than one enabledCollection, creating an internal link to a doc created through the link UI always saves the relationTo as the first collection in the enabledCollections array. At best, it prevents saving with a validation error. At worst, this causes the user to save an incorrect link unknowingly.
Link to the code that reproduces this issue
https://github.com/payloadcms/payload/blob/main/templates/website
Reproduction Steps
The bug is present in the website template, so we'll use that.
- Create or edit an existing doc in the
Pagescollection. - In a rich text field (ex:
hero.richText) add a link. - Change the link to "internal link" and create a new doc in any collection but the first (in this case,
Posts).

- Fill the required fields and save and close then new doc.
- Notice the link is now pointing to a (potentially invalid) doc from the first collection (in this case,
Pages)

- Save and close the link, and try to save the page where you made the link. If the doc ID is invalid, you will see this error:

Which area(s) are affected? (Select all that apply)
db: postgres, area: docs, plugin: richtext-lexical
Environment Info
Payload: 3.63.0
Node.js: 22.X (deployed on vercel)
Next.js: 15.4.7
rilrom