Relationship field with admin appearance set to drawer is not working when the other collection is using richtext as title
Describe the Bug
if you have a relationship field, and set its admin appearance to drawer for example:
{
name: 'question',
type: 'relationship',
relationTo: 'multiple-choice-questions',
admin: {
appearance: 'drawer',
}
}
then in the multiple-choice-questions collection you have:
{
slug: 'multiple-choice-questions',
admin: {
useAsTitle: 'question',
},
fields: [
{
name: 'question',
type: 'richText',
required: true,
},
]
}
the drawer on the relationship will not work, it will behave strangely, first when try to click the question it tries to take you to the other document edit view and when you click return on broswer then the first collection you were working on becomes unresponsive
Link to the code that reproduces this issue
https://github.com/payloadcms/payload
Reproduction Steps
1- create a collection and give it one richtext field 2-make the richtext as title in colleciton admin property 3- create another colleciotn 4-make a relationship to the first collection in the secone one 5- set the field admin appearnace to drawer 6- run the project 7- go to admin panel 8- create one document for the first collection 9- try to link the created document using the drawer
Which area(s) are affected? (Select all that apply)
area: ui
Environment Info
Binaries:
Node: 22.19.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
payload: 3.58.0
next: 15.5.3
@payloadcms/db-mongodb: 3.58.0
@payloadcms/email-nodemailer: 3.58.0
@payloadcms/graphql: 3.58.0
@payloadcms/next/utilities: 3.58.0
@payloadcms/payload-cloud: 3.58.0
@payloadcms/plugin-cloud-storage: 3.58.0
@payloadcms/plugin-import-export: 3.58.0
@payloadcms/plugin-stripe: 3.58.0
@payloadcms/richtext-lexical: 3.58.0
@payloadcms/storage-s3: 3.58.0
@payloadcms/translations: 3.58.0
@payloadcms/ui/shared: 3.58.0
react: 19.1.1
react-dom: 19.1.1
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Home
Available memory (MB): 65274
Available CPU cores: 32
I've investigated this issue and found the root cause.
Root Cause
When a relationship field uses appearance: 'drawer' and the related collection has a richText field as useAsTitle, the custom cell component (Lexical's RscEntryLexicalCell) was being rendered via RenderCustomComponent, which bypassed RenderDefaultCell.
RenderDefaultCell is the client component responsible for reading the drawer context and setting up the onClick handler for item selection. Since the richText cell bypassed this, it received link: true (from server-side rendering) and rendered as a Link component that navigated away instead of selecting the item.
Solution
- Modified
RenderDefaultCellto accept acustomCellprop for custom cell components - When a custom cell exists in a drawer context, wrap it with a button that captures clicks using
onClickCaptureand prevents nested Link components from navigating - Updated
renderCell.tsxto always useRenderDefaultCell, passing custom cells as a prop
This ensures all cells (custom or default) properly handle the drawer context for selection behavior.
I have a fix ready and will open a PR shortly.