Repository navigation
Description
Documentation Issue
Summary
The official docs examples for admin edit-view custom components (notably EditMenuItems) show usage of props.id (the document id) inside server components, but in the codebase the serverProps passed to admin custom components do not include an id (both the TypeScript types and runtime construction lack it). As a result props.id is undefined at runtime and the docs are misleading.
Note: BeforeDocumentControls shows the same problem — its docs/examples also imply access to props.id, but the server props do not provide it.
Additional Details
Reproduction steps
- Create an
EditMenuItemsserver component using the docs example that referencesprops.id, for example:
import React from 'react'
import { PopupList } from '@payloadcms/ui'
import type { EditMenuItemsServerProps } from 'payload'
export const EditMenuItems = async (props: EditMenuItemsServerProps) => {
const href = `/custom-action?id=${props.id}` // expects props.id
return (
<PopupList.ButtonGroup>
<PopupList.Button href={href}>Custom Edit Menu Item</PopupList.Button>
<PopupList.Button href={href}>
Another Custom Edit Menu Item - add as many as you need!
</PopupList.Button>
</PopupList.ButtonGroup>
)
}- Register this component in a collection config as
admin.components.edit.editMenuItems. - Open the document edit page in the admin UI.
(Repeat the analogous steps for BeforeDocumentControls using its docs example.)
Observed behavior (actual)
props.idisundefinedat runtime forEditMenuItems(and likewise forBeforeDocumentControlswhen following the docs).- The TypeScript types for
EditMenuItemsServerProps(and the corresponding types used forBeforeDocumentControls) do not include anidfield. - The
serverPropsobject that is passed to these components at render time (inrenderDocumentSlots.tsx) does not contain the document id. - Current consumer workaround: read the id from
window.locationon the client side (fragile and not server-render-friendly).
Expected behavior (documentation / expectation)
- The docs examples imply that the document
idis available on server component props (props.id). The actual codebase does not provide this value inserverProps. Documentation and runtime/types should match so examples are accurate and not misleading.
Evidence / references (from official docs & repo inspected)
-
Docs example referencing
props.idforEditMenuItems:
https://payloadcms.com/docs/custom-components/edit-view#editmenuitems -
EditMenuItemselement / types (noidin props):
https://github.com/payloadcms/payload/blob/9c8f3202e4130fe70f7b18a1e66ac2d37d04a992/packages/payload/src/admin/elements/EditMenuItems.ts -
Where server props are constructed and passed to custom components (no
idincluded):
https://github.com/payloadcms/payload/blob/9c8f3202e4130fe70f7b18a1e66ac2d37d04a992/packages/next/src/views/Document/renderDocumentSlots.tsx -
Note:
BeforeDocumentControlsexhibits the same docs vs. runtime mismatch (docs/examples referenceprops.id, butserverPropspassed at render time do not includeid).
Workaround currently used by consumers
- Parse
window.locationon the client to extract the document id from the URL path/query.
Activity
fix: server edit view components don't receive document id prop (payl…
github-actions commentedon Aug 21, 2025
🚀 This is included in version v3.53.0
github-actions commentedon Aug 29, 2025
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.