Skip to content

Commit 91e8acc

Browse files
authored
fix: cannot pass function to client error when defining server-only props in custom field components (#9898)
Fixes #9895 We were still including field custom components in the ClientConfig, which will throw an error if actual server-only properties were passed to `PayloadComponent.serverProps`. This PR removes them from the ClientConfig
1 parent b83ea84 commit 91e8acc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/payload/src/fields/config/client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export type ServerOnlyFieldProperties =
3737
| 'validate'
3838
| keyof Pick<FieldBase, 'access' | 'custom' | 'defaultValue' | 'hooks'>
3939

40-
export type ServerOnlyFieldAdminProperties = keyof Pick<FieldBase['admin'], 'condition'>
40+
export type ServerOnlyFieldAdminProperties = keyof Pick<
41+
FieldBase['admin'],
42+
'components' | 'condition'
43+
>
4144

4245
const serverOnlyFieldProperties: Partial<ServerOnlyFieldProperties>[] = [
4346
'hooks',
@@ -57,7 +60,10 @@ const serverOnlyFieldProperties: Partial<ServerOnlyFieldProperties>[] = [
5760
// `tabs`
5861
// `admin`
5962
]
60-
const serverOnlyFieldAdminProperties: Partial<ServerOnlyFieldAdminProperties>[] = ['condition']
63+
const serverOnlyFieldAdminProperties: Partial<ServerOnlyFieldAdminProperties>[] = [
64+
'condition',
65+
'components',
66+
]
6167
type FieldWithDescription = {
6268
admin: AdminClient
6369
} & ClientField

test/fields/collections/Array/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ const ArrayFields: CollectionConfig = {
3232
type: 'ui',
3333
admin: {
3434
components: {
35-
Field: './collections/Array/LabelComponent.js#ArrayRowLabel',
35+
Field: {
36+
path: './collections/Array/LabelComponent.js#ArrayRowLabel',
37+
serverProps: {
38+
// While this doesn't do anything, this will reproduce a bug where having server-only props in here will throw a "Functions cannot be passed directly to Client Components" error
39+
someFn: () => 'Hello',
40+
},
41+
},
3642
},
3743
},
3844
},

0 commit comments

Comments
 (0)