fix(plugin-nested-docs): crumbs not syncing on non-versioned collections (#13629)

Fixes https://github.com/payloadcms/payload/issues/13563

When using the nested docs plugin with collections that do not have
drafts enabled. It was not syncing breadcrumbs from parent changes.

The root cause was returning early on any document that did not meet
`doc._status !== 'published'` check, which was **_always_** the case for
non-draft collections.

### Before
```ts
if (doc._status !== 'published') {
  return
}
```
### After
```ts
if (collection.versions.drafts && doc._status !== 'published') {
  return
}
```
This commit is contained in:
Jarrod Flesch
2025-08-28 15:43:31 -04:00
committed by GitHub
parent c1b4960795
commit 4600c94cac
8 changed files with 121 additions and 102 deletions

View File

@@ -179,19 +179,15 @@ describe('@payloadcms/plugin-nested-docs', () => {
})
.then(({ docs }) => docs[0])
if (!updatedChild) {
return
}
// breadcrumbs should be updated
expect(updatedChild.breadcrumbs).toHaveLength(2)
expect(updatedChild!.breadcrumbs).toHaveLength(2)
expect(updatedChild.breadcrumbs?.[0]?.url).toStrictEqual('/parent-updated')
expect(updatedChild.breadcrumbs?.[1]?.url).toStrictEqual('/parent-updated/child')
expect(updatedChild!.breadcrumbs?.[0]?.url).toStrictEqual('/parent-updated')
expect(updatedChild!.breadcrumbs?.[1]?.url).toStrictEqual('/parent-updated/child')
// no other data should be affected
expect(updatedChild.title).toEqual('child doc')
expect(updatedChild.slug).toEqual('child')
expect(updatedChild!.title).toEqual('child doc')
expect(updatedChild!.slug).toEqual('child')
})
})