payload icon indicating copy to clipboard operation
payload copied to clipboard

nested-docs-plugin error when updating slug for parent entries

Open tiago-meireles opened this issue 1 year ago • 0 comments

Link to reproduction

No response

Payload Version

beta.87

Node Version

20 LTS

Next.js Version

15.0.0-canary.104

Describe the Bug

I'm experiencing the same exact error Nested Docs plugin has had an error while re-saving a child document as published that's also described here: https://github.com/payloadcms/payload/issues/7694 in which the relationship between parent and child entries in a collection are not working as expected.

For example:

  1. I'm able to create a Parent page and then a child page for this parent with no problem.
  2. If I to update the slug of the Parent page, this change is not published because of the Nested Docs plugin has had an error while re-saving a child document as published error and the child page breadcrumbs are not updated to match the new parent page slug.
  3. If I update the slug of the child page, the new breadcrumbs still use the previous parent slug.

Here are the steps I described above (used the beta.87 of the payload beta demo):

https://github.com/user-attachments/assets/d770410a-6eb4-442c-b5aa-8156f3caa320

This's the nested docs plugin configuration I'm using:

    nestedDocsPlugin({
      collections: ['pages', 'categories'],
      generateLabel: (_, doc) => doc['title'] as string,
      generateURL: (docs) => docs.reduce((url, doc) => `${url}/${doc['slug'] as string}`, ''),
    }),

The only way I have to update the parent/child breadcrumbs to their correct values is to remove the relationship to the parent from the child page and published it, then go to the parent page and publish it (no child == no nested docs error) and then add the parent relationship again.

Also, not sure if this is the expected behaviour from the plugin-nested-docs, but currently it's possible to published a Child page when the Parent page that's related is still a draft. In these cases, the breadcrumbs of the Child page will look like this: image

Reproduction Steps

  1. Use the beta demo project
  2. Update to version 87
  3. Change (if necessary) the nested docs plugin configuration to the one described above
  4. Create the Parent and Child pages as described in the video
  5. See that the Parent page cannot the published and the slug changes are not present in the child pages

Adapters and Plugins

plugin-nested-docs

tiago-meireles avatar Aug 21 '24 13:08 tiago-meireles