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 filter not adding items to dropdown after making request for next page #5922

Open
mrstebo opened this issue Apr 19, 2024 · 0 comments
Labels
[possible-bug] Possible bug which hasn't been reproduced yet

Comments

@mrstebo
Copy link

mrstebo commented Apr 19, 2024

Link to reproduction

No response

Describe the Bug

This is an issue I have found in Payload 1.13.4, but have also upgraded to 1.15.8 which has the same issue.

I have a collection called "Group Posts". In that collection I have a field called "Groups" that is a relationship. When I try and filter by the "Groups" field from the Group Posts list page it only brings back the first page when I try and search for a specific group.

Looking at the network tab it is making an initial request with the search criteria in the request. Then, when scrolling to the bottom of the list, it will make another request to page 2 (without the search query string, but maybe that isn't an issue as this is similar behaviour in the latest versions of Payload). However, after this request is made, no new items are added to the dropdown.

To Reproduce

Create a collection called Groups:

import { CollectionConfig } from "payload/types";

export const Groups: CollectionConfig = {
  slug: "groups",
  admin: {
    useAsTitle: "name",
  },
  fields: [
    {
      name: "name",
      type: "text",
      required: true,
    },
  ],
};

Create a collection called GroupPosts:

import { CollectionConfig } from "payload/types";

export const GroupPosts: CollectionConfig = {
  slug: "groupPosts",
  fields: [
    {
      name: "text",
      type: "text",
      required: true,
    },
    {
      name: "group",
      type: "relationship",
      relationTo: "groups",
      hasMany: true,
      required: true,
    },
  ],
};

Update the onInit method so we can create multiple groups. We don't need to create any group posts.

for (let i = 1; i <= 50; i++) {
  await payload.create({
    collection: "groups",
    data: {
      name: `My Group ${i}`,
    },
  });
}

// Create non-related groups
await Promise.all(
  ["Animals", "Axolotl", "Badger", "Cats", "Dogs", "Fish", "Parrot"].map((tagName) =>
    payload.create({
      collection: "groups",
      data: {
        name: tagName,
      },
    }),
  ),
);

Then go to the Group Posts page in the admin area and create a new filter for the Groups field. Enter "My Group", and attempt to scroll past the first batch of results in the dropdown.

Payload Version

1.15.8

Adapters and Plugins

db-mongodb, plugin-cloud-storage, plugin-seo

@mrstebo mrstebo added the [possible-bug] Possible bug which hasn't been reproduced yet label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[possible-bug] Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

1 participant