craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.26k stars 634 forks source link

[5.x]: Nested entries edited while in a draft are auto-applied to parent entry #15956

Open gateszies opened 3 hours ago

gateszies commented 3 hours ago

What happened?

Description

Our authors are facing a similar problem as discussed over here. We're using a Matrix-based page builder with nested entries displayed as cards. This has been a huge upgrade for authoring pages, but we've been running into an issue related to drafts. When authors create a draft on the page, they expect that any edits made to the page sections will be included in the memory of that draft. Instead, any edits made to the nested entries are auto-saved to the current version of the page. https://github.com/user-attachments/assets/eef32195-f739-4080-b442-6b05b45aa81a

Steps to reproduce

  1. Create a draft on a page
  2. Edit a nested entry section
  3. Go to the current version of the page and check the edited section
  4. The edits made to the edited nested entry section are now applied to the current version of the page

Expected behavior

When creating a draft on a page, the nested entry content should be tied to that page draft. The revisions should not be auto-applied to the current version of the page until the page draft is applied.

Actual behavior

Edits made to nested entries while in a page draft are auto-applied to the current version of the page. Especially on a page that exclusively uses a page builder with nested entries, this makes the concept of a page draft non-functional.

Craft CMS version

5.4.7.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

gateszies commented 3 hours ago

It seems the current advice would be to create individual drafts for each nested entry. This has a few problems - the first being that there isn't a way to create a draft in the nested entry drawer view. Our authors are primarily using the slide-out panels to edit elements on a page but the only place to create a draft is if the nested entry is opened in a new tab. Image

The bigger issue is the overall draft functionality on nested entries. When an author goes to edit a page with page builder content, they expect that the nested content is in the context of the overall page draft, and therefore shouldn't get applied to the current version unless the page draft is applied. I can see instances where this might not be the case, but in the context of a page builder, it's crucial to have all nested entries tied to overall page draft.

The below shows what a typical page looks like in this context. Currently the only way to use drafts is to individually open each section in a new tab, create a draft for each, and subsequently manage and apply every draft on every section. Image

gateszies commented 3 hours ago

I would echo an updated Matrix configuration solution proposed over here.

I don't think there's a single solution that will work for all use-cases. In my opinion, those two modes of operation should be an option on matrix fields, so I as a developer can decide which mode of operation I want for every matrix field. I imagine a configuration on matrix fields with two options:

  • Nested entries share their owner's life-cycle. Changes in a pop-out are saved as provisional drafts, and applied when the parent entry is saved.
  • Nested entries have their own life-cycle. Changes to nested entries are applied immediately upon saving.