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

Data passed to filterOptions sometimes without enriched data from read hooks #10075

Open
mzronek opened this issue Dec 19, 2024 · 0 comments
Open
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@mzronek
Copy link

mzronek commented Dec 19, 2024

Describe the Bug

We are filtering a relationship field using filterOptions with data, that is added to a document in an afterRead/beforeRead hook. Sometimes the data argument is passed with the enriched property, sometimes it is not. That results in the field entries not being filtered correctly. In my reproduction I also couldn't save the entry when the undefined filter removed all options from the field.

Link to the code that reproduces this issue

https://github.com/mzronek/payload-bug-filter

Reproduction Steps

Steps:

  1. Create a second user
  2. Create a new Test entry
  3. Save Test entry (beforeRead/afterRead not called before entry is saved)
  4. Select user again and again until the issue comes up

Result: Only shows a single user, although both should be shown.
Console shows: DATA FILTER undefined

To test beforeRead, comment afterRead hook, uncomment beforeRead hook in Test.ts.

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 22.11.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.9.0
  next: 15.1.0
  @payloadcms/db-postgres: 3.9.0
  @payloadcms/email-nodemailer: 3.9.0
  @payloadcms/graphql: 3.9.0
  @payloadcms/next/utilities: 3.9.0
  @payloadcms/payload-cloud: 3.9.0
  @payloadcms/richtext-lexical: 3.9.0
  @payloadcms/translations: 3.9.0
  @payloadcms/ui/shared: 3.9.0
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Home
  Available memory (MB): 65241
  Available CPU cores: 32
@mzronek mzronek added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction labels Dec 19, 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