Skip to content

Commit 09ca514

Browse files
authored
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
1 parent f1b005c commit 09ca514

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/plugin-nested-docs/src/utilities/formatBreadcrumb.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ export const formatBreadcrumb = (
1919
if (typeof pluginConfig?.generateLabel === 'function') {
2020
label = pluginConfig.generateLabel(docs, lastDoc)
2121
} else {
22-
const useAsTitle = collection?.admin?.useAsTitle || 'id'
23-
label = lastDoc[useAsTitle] as string
22+
const title = lastDoc[collection.admin.useAsTitle]
23+
24+
label = typeof title === 'string' || typeof title === 'number' ? String(title) : ''
2425
}
2526

2627
return {

0 commit comments

Comments
 (0)