Skip to content

Conversation

@RajeshKumar11
Copy link

Summary

  • Fixes relationship drawer selection when the related collection uses a richText field as useAsTitle
  • When clicking an item in the drawer, it now properly selects the item instead of navigating away to the edit page
  • Custom cell components (like Lexical richText cells) now go through RenderDefaultCell to ensure drawer context is properly handled

Problem

When a relationship field uses appearance: 'drawer' and the related collection has a richText field as useAsTitle, clicking an item in the drawer would navigate to the edit page instead of selecting it.

This happened because custom cell components were rendered via RenderCustomComponent, bypassing RenderDefaultCell which handles drawer context and click selection.

Solution

  • Modified RenderDefaultCell to accept a customCell prop for custom cell components
  • When a custom cell exists in drawer context, it's wrapped with a button that captures clicks using onClickCapture and prevents nested Link components from navigating
  • Updated renderCell.tsx to always use RenderDefaultCell, passing custom cells as a prop

Test plan

  • Navigate to a collection with a relationship field that has appearance: 'drawer'
  • The related collection should have a richText field as useAsTitle
  • Click on the relationship field to open the drawer
  • Click on an item in the list
  • Verify the item is selected and the drawer closes (instead of navigating to edit page)

Fixes #14050

When a relationship field uses `appearance: 'drawer'` and the related
collection has a richText field as `useAsTitle`, clicking an item in
the drawer would navigate to the edit page instead of selecting it.

This happened because custom cell components (like the Lexical richText
cell) were rendered via RenderCustomComponent, bypassing RenderDefaultCell
which handles drawer context and click selection.

The fix ensures all cells go through RenderDefaultCell, which now accepts
a `customCell` prop. When a custom cell exists in drawer context, it's
wrapped with a button that captures clicks and prevents nested Link
components from navigating.

Fixes payloadcms#14050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relationship field with admin appearance set to drawer is not working when the other collection is using richtext as title

1 participant