Relationship field: filter on wrong field with defaultSort
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
I'm just pushing here, I suppose this is a small thing but it makes the defaultSort property practically unusable.
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
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.