-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Describe the Bug
This update 21599b8 introduced in payload 3.35 has essentially removed the ability to directly pass in a path to a payload UI element inside a custom component when a parent context has been set with no way to change the context.
For example prior to the update I could add payload fields to a custom component as such:
<RadioGroupField
key={`${path}.${performanceSyncTypeClientField.name}`}
field={performanceSyncTypeClientField}
path={`${path}.${performanceSyncTypeClientField.name}`}
readOnly={connectedField.value}
/>
This was needed as I have several complex components that also render payload fields with minor additional features added (like the readOnly change above)
However since the 35 update it looks like every payloadUI element uses a useField funxtion to obtain its path and this useField function will first check if a path context is set before attempting to use the provided path.
This context is set outside of my control s and there is no way to change it since it is locked in a file inside the payloadCMS that is not exposed to the framework.
I was able to trigger this bug by having a custom group component that addressed the fields within it.
Link to the code that reproduces this issue
https://discord.com/channels/967097582721572934/1366759797591900190/1366759797591900190
Reproduction Steps
-
Create a group field with fields within it.
-
Create a custom ui component for said group
-
- Within this custom group UI component attempt to use a payload/ui field such as RadioGroupField padding in the correct client field from the group
-
- Pass in the correct path to this RadioGroupField field
-
You will notice the RadioGroupField path provided by the prop will be ignored and instead only the parent groups path will be used due to it being set by its parents context
Which area(s) are affected? (Select all that apply)
area: ui
Environment Info
Binaries:
Node: 22.6.0
npm: 10.8.2
Yarn: N/A
pnpm: 9.15.9
Relevant Packages:
payload: 3.35.0
next: 15.3.0
@payloadcms/db-mongodb: 3.35.0
@payloadcms/email-nodemailer: 3.35.0
@payloadcms/graphql: 3.35.0
@payloadcms/live-preview: 3.35.0
@payloadcms/live-preview-react: 3.35.0
@payloadcms/next/utilities: 3.35.0
@payloadcms/payload-cloud: 3.35.0
@payloadcms/plugin-cloud-storage: 3.35.0
@payloadcms/plugin-form-builder: 3.35.0
@payloadcms/plugin-redirects: 3.35.0
@payloadcms/plugin-search: 3.35.0
@payloadcms/plugin-seo: 3.35.0
@payloadcms/plugin-stripe: 3.35.0
@payloadcms/richtext-lexical: 3.35.0
@payloadcms/storage-s3: 3.35.0
@payloadcms/translations: 3.35.0
@payloadcms/ui/shared: 3.35.0
react: 19.1.0
react-dom: 19.1.0
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
Available memory (MB): 16384
Available CPU cores: 10