You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Nested Docs Plugin, the resaveChildren hook is intended to cascade changes to child documents when a parent document is updated. However, the expected flow, in my opinion, is incomplete:
When a parent document's slug is updated and published, the changes cascade only to the draft version of child documents, leaving the published child documents unchanged.
This behavior can result in broken links or outdated breadcrumbs in published child documents until the draft is manually published.
The published child document should be updated to reflect the new parent slug and maintain live content consistency.
If a child draft exists, it should also be updated while preserving the draft's unpublished state.
If this is not the expected behavior, the resaveChildren hook and associated logic should be updated to clearly reflect this design decision, removing unused parameters and redundant code.
Current Behavior:
The resaveChildren calls the resave function with both draft: true and draft: false (if the doc is published) but the parameter is no longer used, causing the draft child documents to be updated while leaving the published child documents unchanged.
Proposed Solution:
Update the resave function logic to handle both draft and published child documents explicitly:
Update the published child document when the parent is published.
Update the draft child document (if it exists) without affecting its draft state.
Link to the code that reproduces this issue
This repo is just the Payload template, no mentionable changes except adding the pages collection to the nested docs config.
Describe the Bug
Description:
In the
Nested Docs Plugin
, theresaveChildren
hook is intended to cascade changes to child documents when a parent document is updated. However, the expected flow, in my opinion, is incomplete:Additionally, the
draft
parameter passed to theresave
function within theresaveChildren
hook is unused due to this recent commit 50e7c24b, leading to duplicate calls and redundant logic.Expected Behavior:
When a parent document's slug is updated:
If this is not the expected behavior, the
resaveChildren
hook and associated logic should be updated to clearly reflect this design decision, removing unused parameters and redundant code.Current Behavior:
resaveChildren
calls theresave
function with bothdraft: true
anddraft: false
(if the doc is published) but the parameter is no longer used, causing the draft child documents to be updated while leaving the published child documents unchanged.Proposed Solution:
Update the
resave
function logic to handle both draft and published child documents explicitly:Link to the code that reproduces this issue
This repo is just the Payload template, no mentionable changes except adding the
pages
collection to the nested docs config.https://github.com/Collexi-Dev/test-payload-3-stable
Reproduction Steps
Which area(s) are affected? (Select all that apply)
plugin: nested-docs
Environment Info
The text was updated successfully, but these errors were encountered: