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

Sorting by an array field breaks the collection list view table #6468

Closed
jackadair opened this issue May 22, 2024 · 0 comments
Closed

Sorting by an array field breaks the collection list view table #6468

jackadair opened this issue May 22, 2024 · 0 comments
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@jackadair
Copy link

Link to reproduction

No response

Describe the Bug

If you have a collection with an array field, and then attempt to sort by it in the list view, it will get stuck loading and throw this error:

Error: Invalid field "" passed to sort()
    at model.Query.exec (.../node_modules/mongoose/lib/query.js:4916:13)
    at Function.paginate (.../node_modules/mongoose-paginate-v2/dist/index.js:191:26)
    at Object.find (.../node_modules/@payloadcms/db-mongodb/src/find.ts:84:30)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at find (.../node_modules/payload/src/collections/operations/find.ts:145:16)
    at findHandler (.../node_modules/payload/src/collections/requestHandlers/find.ts:30:20)
Screen.Recording.2024-05-22.at.4.34.58.PM.mov

To Reproduce

  1. Create a collection with a field of type "array" ex.
import { CollectionConfig } from "payload/types";

export const Test: CollectionConfig = {
    slug: "test",
    admin: {
        useAsTitle: "name",
    },
    access: {
        create: () => true,
        read: () => true,
        update: () => true,
        delete: () => true,
    },
    fields: [
        {
            name: "tests",
            type: "array",
            fields: [
                {
                    name: "test",
                    type: "text",
                    required: true,
                },
                {
                    name: "test2",
                    type: "text",
                    required: true,
                },
            ]
        }
    ],
}

Payload Version

2.8.2

Adapters and Plugins

db-mongodb

@jackadair jackadair added the status: needs-triage Possible bug which hasn't been reproduced yet label May 22, 2024
@jackadair jackadair closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

1 participant