payload icon indicating copy to clipboard operation
payload copied to clipboard

Relationship field: filter on wrong field with defaultSort

Open Janisvb opened this issue 2 years ago • 2 comments

Link to reproduction

https://github.com/Janisvb/payload-reproduction/tree/relationship-search

Describe the Bug

When defaultSort is set, the relationship field seems to filter on the defaultSearch-field rather than on the useAsTitle-field. This leads to errors, if the defaultSort-field is not a text-based field.

https://github.com/payloadcms/payload/assets/7983986/ee74eeee-d728-4def-a2ce-f509ac549f73

To Reproduce

yarn dev _community

Payload Version

2.8.1

Adapters and Plugins

db-postgres, bundler-webpack

Janisvb avatar Jan 15 '24 10:01 Janisvb

I'm just pushing here, I suppose this is a small thing but it makes the defaultSort property practically unusable.

linobino1 avatar Apr 02 '24 11:04 linobino1

I also got hit by this.

Seems defaultSort is used for fieldToSearch: https://github.com/payloadcms/payload/blob/9152a238d2982503e7f509350651b0ba3f83b1ec/packages/payload/src/admin/components/forms/field-types/Relationship/index.tsx#L149

andershermansen avatar Apr 23 '24 06:04 andershermansen

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Sep 07 '24 04:09 github-actions[bot]