-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Description
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:
- Create a second user
- Create a new Test entry
- Save Test entry (beforeRead/afterRead not called before entry is saved)
- 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
rolandsaven
Metadata
Metadata
Assignees
Labels
No labels