fix(plugin-nested-docs): fallback to empty string if useAsTitle field is undefined (#11338)
Updated `formatBreadcrumb` to fall back to an empty string if the `useAsTitle` field for the document is undefined. This handles cases where the field is optional or not filled out, ensuring the label is never `undefined`. Fixes #10377
This commit is contained in:
@@ -19,8 +19,9 @@ export const formatBreadcrumb = (
|
||||
if (typeof pluginConfig?.generateLabel === 'function') {
|
||||
label = pluginConfig.generateLabel(docs, lastDoc)
|
||||
} else {
|
||||
const useAsTitle = collection?.admin?.useAsTitle || 'id'
|
||||
label = lastDoc[useAsTitle] as string
|
||||
const title = lastDoc[collection.admin.useAsTitle]
|
||||
|
||||
label = typeof title === 'string' || typeof title === 'number' ? String(title) : ''
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user