Skip to content

Commit 6848cf4

Browse files
authored
fix(ui): passes serverProps to custom label components within table columns (#10547)
Continuation of #10540. Passes server props to custom label components rendered within table columns, such as the list view. This way custom server components can have access to `payload`, `i18n`, etc. as expected.
1 parent 2e0595b commit 6848cf4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/ui/src/elements/TableColumns/buildColumnState.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
PaginatedDocs,
1111
Payload,
1212
SanitizedCollectionConfig,
13+
ServerComponentProps,
1314
StaticLabel,
1415
} from 'payload'
1516

@@ -170,11 +171,23 @@ export const buildColumnState = (args: Args): Column[] => {
170171
field,
171172
}
172173

174+
const serverProps: Pick<
175+
ServerComponentProps,
176+
'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'
177+
> = {
178+
clientField: field,
179+
collectionSlug: collectionConfig.slug,
180+
field: _field,
181+
i18n,
182+
payload,
183+
}
184+
173185
const CustomLabel = CustomLabelToRender
174186
? RenderServerComponent({
175187
clientProps,
176188
Component: CustomLabelToRender,
177189
importMap: payload.importMap,
190+
serverProps,
178191
})
179192
: undefined
180193

@@ -201,12 +214,6 @@ export const buildColumnState = (args: Args): Column[] => {
201214
rowData: undefined,
202215
}
203216

204-
const serverProps: Pick<DefaultServerCellComponentProps, 'field' | 'i18n' | 'payload'> = {
205-
field: _field,
206-
i18n,
207-
payload,
208-
}
209-
210217
const column: Column = {
211218
accessor: 'name' in field ? field.name : undefined,
212219
active,

0 commit comments

Comments
 (0)