payloadcms / payloadcms/payload
bug: bulk edit drawer drops values from custom field components
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
In the list view's bulk edit drawer ("Edit"), any field rendered by a custom field component silently drops its value. The drawer reports success and bumps updatedAt, but the field is never written.
This affects @payloadcms/plugin-seo out of the box: meta.title, meta.description and meta.image are all custom components, so SEO metadata cannot be bulk edited at all.
Root cause
RenderFields/index.tsx#L88wraps every field in a<FieldPathContext value={path}>provider. This is what makes custom components work in the normal document edit view.EditMany/DrawerContent.tsx#L409callsRenderFielddirectly rather than going throughRenderFields, so there is noFieldPathContextprovider. It passespathas a prop instead.RenderField.tsx#L71short-circuits for custom components:if (CustomField !== undefined) { return CustomField }.CustomFieldis a pre-rendered element taken from form state, so thepathprop is dropped.MetaTitleComponent.tsx#L62(andMetaDescriptionComponent.tsx#L69,MetaImageComponent.tsx#L53) callsuseField()with no arguments.useFieldfalls back touseFieldPath()(useField/index.tsx#L40), which returnsundefined.setValuetherefore writes to the form-state keyundefined. On submit,reduceFieldsToValues(fields, true)unflattens that into a top-level"undefined"property.- Server-side
"undefined"is not a field in the schema and is discarded, so nothing is written — but the update still succeeds with200 OK.
The FieldPathContext docblock (RenderFields/context.ts#L6) warns about exactly this: "if you render a field directly, you will need to wrap it with a new FieldPathContext provider." EditMany/DrawerContent.tsx does not. Note that BulkUpload/EditMany/DrawerContent.tsx#L196 does use the provider (with value={undefined}), so the two EditMany implementations diverge here.
This is the custom-component half of the same defect as #10571, which was closed as a duplicate of the group bug #10019 and fixed at the group level in v3.29.0.
Observed behaviour in the reproduction
The input rendered in the drawer gets id="field-undefined", and the PATCH body is:
{ "undefined": "seo only bulk title", "meta": {} }
A plain custom text field (no plugin involved) behaves identically, confirming the bug is in @payloadcms/ui and not in plugin-seo:
{ "undefined": "customtext only" }
Link to the code that reproduces this issue
Reproduction Steps
- Clone this repo and open the
bulk-edit-drops-custom-field-values/directory pnpm install && cp .env.example .envpnpm devand log in at http://localhost:3000/admin asdev@example.com/test(two pages are seeded on first start)- Go to Collections → Pages, tick the select-all checkbox, press Edit
- In "Select fields to edit" choose SEO > Title, type any value, press Save
- Expected:
meta.titleis updated on both pages. Actual: the toast says "2 Pages successfully updated" andupdatedAtis bumped, butmeta.titleis unchanged. The input's id isfield-undefinedand the PATCH body contains{"undefined": "<your value>", "meta": {}}.
Selecting Custom Text instead — a plain custom component defined in this reproduction that calls useField() the same way plugin-seo does — reproduces the same result without any plugin.
Which area(s) are affected?
area: ui
plugin: seo
Environment Info
Binaries:
Node: 22.19.0
npm: 10.9.3
Yarn: N/A
pnpm: 11.5.1
Relevant Packages:
payload: 3.88.0
next: 16.3.4
@payloadcms/db-sqlite: 3.88.0
@payloadcms/drizzle: 3.88.0
@payloadcms/graphql: 3.88.0
@payloadcms/next/utilities: 3.88.0
@payloadcms/plugin-seo: 3.88.0
@payloadcms/richtext-lexical: 3.88.0
@payloadcms/translations: 3.88.0
@payloadcms/ui/shared: 3.88.0
react: 19.2.8
react-dom: 19.2.8
Operating System:
Platform: darwin
Arch: arm64
Available memory (MB): 24576
Available CPU cores: 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the FieldPathContext usage in packages/ui/src/forms/RenderFields/index.tsx with the direct RenderField call in packages/ui/src/elements/EditMany/DrawerContent.tsx. Run the linked bulk-edit reproduction and inspect the custom field components and PATCH body. Done means custom fields retain their paths and bulk editing updates values such as meta.title instead of writing an undefined key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100