Skip to content

Commit 68b5f61

Browse files
authored
fix: ensure tab label and description are serializable (#10115)
<!-- Thank you for the PR! Please go through the checklist below and make sure you've completed all the steps. Please review the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository if you haven't already. The following items will ensure that your PR is handled as smoothly as possible: - PR Title must follow conventional commits format. For example, `feat: my new feature`, `fix(plugin-seo): my fix`. - Minimal description explained as if explained to someone not immediately familiar with the code. - Provide before/after screenshots or code diffs if applicable. - Link any related issues/discussions from GitHub or Discord. - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Fixes # --> ### What? This PR fixes an issue where assigning a label or description function to a tab would cause a runtime error due to passing a function to a client component. ### Why? To prevent runtime errors when using non-static designations. ### How? By properly evaluating label and description functions prior to assignment to their `clientTab` counterpart. Fixes #10114 Before: ![image](https://github.com/user-attachments/assets/e003780a-2f24-4988-96ce-27c22fd61854) After: ![image](https://github.com/user-attachments/assets/0bd185a0-415d-4414-bead-48647e244ba7)
1 parent 1372f24 commit 68b5f61

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ export const createClientField = ({
292292
continue
293293
}
294294

295+
const tabProp = tab[key]
296+
295297
if (key === 'fields') {
296298
clientTab.fields = createClientFields({
297299
defaultIDType,
@@ -300,8 +302,13 @@ export const createClientField = ({
300302
i18n,
301303
importMap,
302304
})
305+
} else if (
306+
(key === 'label' || key === 'description') &&
307+
typeof tabProp === 'function'
308+
) {
309+
clientTab[key] = tabProp({ t: i18n.t })
303310
} else {
304-
clientTab[key] = tab[key]
311+
clientTab[key] = tabProp
305312
}
306313
}
307314
field.tabs[i] = clientTab

test/_community/payload-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,4 @@ export interface Auth {
336336
declare module 'payload' {
337337
// @ts-ignore
338338
export interface GeneratedTypes extends Config {}
339-
}
339+
}

0 commit comments

Comments
 (0)