Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship field: filter on wrong field with defaultSort #4815

Open
Janisvb opened this issue Jan 15, 2024 · 2 comments · May be fixed by #5964
Open

Relationship field: filter on wrong field with defaultSort #4815

Janisvb opened this issue Jan 15, 2024 · 2 comments · May be fixed by #5964
Assignees
Labels
db-mongodb @payloadcms/db-mongodb [reproduced] If an issue has been reproduced

Comments

@Janisvb
Copy link

Janisvb commented Jan 15, 2024

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.

CleanShot.2024-01-15.at.11.38.30.mp4

To Reproduce

yarn dev _community

Payload Version

2.8.1

Adapters and Plugins

db-postgres, bundler-webpack

@Janisvb Janisvb added the [possible-bug] Possible bug which hasn't been reproduced yet label Jan 15, 2024
@DanRibbens DanRibbens self-assigned this Jan 15, 2024
@DanRibbens DanRibbens added [reproduced] If an issue has been reproduced db-mongodb @payloadcms/db-mongodb and removed [possible-bug] Possible bug which hasn't been reproduced yet labels Jan 15, 2024
linobino1 pushed a commit to linobino1/kino that referenced this issue Mar 2, 2024
@linobino1
Copy link

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

@andershermansen
Copy link

I also got hit by this.

Seems defaultSort is used for fieldToSearch:

let fieldToSearch = collection?.defaultSort || collection?.admin?.useAsTitle || 'id'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db-mongodb @payloadcms/db-mongodb [reproduced] If an issue has been reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants