Skip to content

[5.x]: Changes to nested elements don't result in a revision being created until the parent is saved #16248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ryansupercool opened this issue Nov 30, 2024 · 5 comments
Labels

Comments

@ryansupercool
Copy link

ryansupercool commented Nov 30, 2024

What happened?

Description

When editing and saving a nested element a revision is not created until after you save the parent despite the changes to nested element being applied to the canonical element. This can be observed when using a Matrix field in table view mode (inline mode does not exhibit this behaviour). We also see this issue within Commerce when managing Products/Variants, as well as in our own nested elements.

Steps to reproduce

Requires a Matrix field with oneEntry type and field. The Matrix field should be set to "Display as an element index" and "Display in a table".

  1. Create a new Entry and save.
  2. A a new Matrix Entry and save, note a revision has been created.
  3. Edit the Matrix Entry and save, note a revision hasn't been created. If you were to view the parent Entry on the frontend you will observe that the Matrix Entry edit is published.
  4. Save the parent Entry, note a revision has now been created.

At the 1:00 minute mark the changes to the Matrix Entry are "live" so it doesn't appear to be a UI bug with the parent Entry not tracking changes. Craft does know something has changed as it will create the revision with the edits to the Matrix Entry when resaving the parent.

Expected behavior

When performing step 3 a revision is created.

Actual behavior

When performing step 3 a revision isn't created.

nested-element-revisions.mp4

Craft CMS version

5.5.4

PHP version

8.2.24

Operating system and version

Linux 6.11.6-orbstack-00279-g28c6c77332e6

Database type and version

MySQL 8.0.36

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

No response

@ryansupercool ryansupercool changed the title [5.x]: Changes to nested elements don't result in revision being created until the parent is saved [5.x]: Changes to nested elements don't result in a revision being created until the parent is saved Nov 30, 2024
@brandonkelly
Copy link
Member

This is working as expected. When you use the element index view mode, the nested entries aren’t really treated as part of the entry content in the way they wood when you use the inline-editable or cards views.

That said, we should at least make it possible for nested entries to track their own revisions. I’ve added that to our Linear project.

@ryansupercool
Copy link
Author

To confirm it's expected that edits to nested elements that are saved don't result in a revision being created on the parent until the parent itself being saved even if there have been no changes on the parent itself?

  1. Create parent and save
  2. Create nested element and save the parent. At this point you have one revision on the parent.
  3. Edit the nested element and save. At this point you still have one revisiosn on the parent and the nested element changes are published.
  4. Save the parent without making further changes to the parent. You now have two revisions on the parent. The first revision is the nested element being created at 2, the second revision contains the edit from 3.

It feels a little confusing that a revision is created a step 4. I would either expect a revision of the parent being created a step 3 (I understand you're saying this shouldn't happen) or no revision is created at step 4 unless changes had occured on the parent itself.

@daltonrooney
Copy link

That said, we should at least make it possible for nested entries to track their own revisions. I’ve added that to our Linear project.

@brandonkelly Is there a GitHub issue for that? Any chance of it being included in 5.7? We’ve had some problems with missing content related to nested elements, I suspect enabling support for revisions may help mitigate the issue.

@brandonkelly
Copy link
Member

Just made it possible to enable versioning for Matrix fields, for Craft 5.7 🎉 (#17008)

@brandonkelly
Copy link
Member

Craft 5.7.0 is out with that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants