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:
Patrik
2025-02-24 14:00:41 -05:00
committed by GitHub
parent f1b005c4f5
commit 09ca5143eb

View File

@@ -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 {