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:  After: 
This commit is contained in:
@@ -292,6 +292,8 @@ export const createClientField = ({
|
||||
continue
|
||||
}
|
||||
|
||||
const tabProp = tab[key]
|
||||
|
||||
if (key === 'fields') {
|
||||
clientTab.fields = createClientFields({
|
||||
defaultIDType,
|
||||
@@ -300,8 +302,13 @@ export const createClientField = ({
|
||||
i18n,
|
||||
importMap,
|
||||
})
|
||||
} else if (
|
||||
(key === 'label' || key === 'description') &&
|
||||
typeof tabProp === 'function'
|
||||
) {
|
||||
clientTab[key] = tabProp({ t: i18n.t })
|
||||
} else {
|
||||
clientTab[key] = tab[key]
|
||||
clientTab[key] = tabProp
|
||||
}
|
||||
}
|
||||
field.tabs[i] = clientTab
|
||||
|
||||
@@ -336,4 +336,4 @@ export interface Auth {
|
||||
declare module 'payload' {
|
||||
// @ts-ignore
|
||||
export interface GeneratedTypes extends Config {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user