Skip to content

fix(plugin-nested-docs): await populateBreadcrumbs in resaveChildren#15582

Merged
JarrodMFlesch merged 2 commits intopayloadcms:mainfrom
wingding12:fix/nested-docs-resave-children-draft-version-loss
Apr 9, 2026
Merged

fix(plugin-nested-docs): await populateBreadcrumbs in resaveChildren#15582
JarrodMFlesch merged 2 commits intopayloadcms:mainfrom
wingding12:fix/nested-docs-resave-children-draft-version-loss

Conversation

@wingding12
Copy link
Copy Markdown
Contributor

@wingding12 wingding12 commented Feb 10, 2026

Fixes #14943

Summary

The async populateBreadcrumbs() function was not being awaited in resaveChildren. This caused payload.update() to receive a Promise instead of the child document's data, so updates couldn't preserve the _status field and defaulted to the main document's draft status.

When a parent was saved, all child updates created draft versions instead of preserving the published/draft distinction. Querying with draft: false then returned draft data, making the published version "disappear."

The fix adds await to the populateBreadcrumbs() call.

…ldren with drafts

When a parent document is saved, the resaveChildren hook updates all
child documents to refresh their breadcrumbs. Previously, when a child
had both a published and a draft version, both were updated sequentially.
This caused createVersion to set `latest = false` on the published
version when the draft version was saved afterward, making the published
version inaccessible on the live site.

The fix skips draft versions for children that also have a published
version — only the published version receives the breadcrumb update.
Draft-only children (never published) continue to be updated normally.

Co-authored-by: Cursor <cursoragent@cursor.com>
@wingding12 wingding12 marked this pull request as ready for review February 17, 2026 23:19
@github-actions github-actions Bot added the stale label Mar 22, 2026
@anatter
Copy link
Copy Markdown

anatter commented Mar 26, 2026

@JarrodMFlesch @jacobsfletch @denolfe May someone please review this pull request? We are affected by this bug and had to disable preview mode on all sites using the nested docs plugin.

@github-actions github-actions Bot removed the stale label Mar 28, 2026
@JarrodMFlesch JarrodMFlesch self-assigned this Apr 7, 2026
The async populateBreadcrumbs function was not being awaited, causing
payload.update() to receive a Promise instead of the child's data.
This made all updates inherit the main document's draft status.
@JarrodMFlesch JarrodMFlesch force-pushed the fix/nested-docs-resave-children-draft-version-loss branch from d384a19 to 4a592b4 Compare April 8, 2026 19:58
@JarrodMFlesch JarrodMFlesch changed the title fix(plugin-nested-docs): preserve published version when resaving children with drafts fix(plugin-nested-docs): await populateBreadcrumbs in resaveChildren Apr 8, 2026
@JarrodMFlesch JarrodMFlesch enabled auto-merge (squash) April 8, 2026 20:02
@JarrodMFlesch JarrodMFlesch disabled auto-merge April 8, 2026 20:02
@JarrodMFlesch JarrodMFlesch merged commit 0554b50 into payloadcms:main Apr 9, 2026
314 of 316 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

🚀 This is included in version v3.82.1

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
…ayloadcms#15582)

Fixes payloadcms#14943

## Summary

The async `populateBreadcrumbs()` function was not being awaited in
`resaveChildren`. This caused `payload.update()` to receive a Promise
instead of the child document's data, so updates couldn't preserve the
`_status` field and defaulted to the main document's draft status.

When a parent was saved, all child updates created draft versions
instead of preserving the published/draft distinction. Querying with
`draft: false` then returned draft data, making the published version
"disappear."

The fix adds `await` to the `populateBreadcrumbs()` call.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-nested-docs: Child documents with drafts lose published version when parent is saved

4 participants