fix(plugin-nested-docs): await populateBreadcrumbs in resaveChildren#15582
Merged
JarrodMFlesch merged 2 commits intopayloadcms:mainfrom Apr 9, 2026
Conversation
…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>
|
@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. |
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.
d384a19 to
4a592b4
Compare
JarrodMFlesch
approved these changes
Apr 9, 2026
Contributor
|
🚀 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14943
Summary
The async
populateBreadcrumbs()function was not being awaited inresaveChildren. This causedpayload.update()to receive a Promise instead of the child document's data, so updates couldn't preserve the_statusfield 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: falsethen returned draft data, making the published version "disappear."The fix adds
awaitto thepopulateBreadcrumbs()call.