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:
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user