-
Notifications
You must be signed in to change notification settings - Fork 684
Description
What happened?
Description
In certain circumstances, Craft throws up an error toast "The canonical owner element must be the primary owner of the nested element" when attempting to save a nested entry, two levels down.
This occurs if the author saves a nested entry that owns nested entries w/ provisional drafts, without first saving those nested-nested entries π΅βπ« (I hope that becomes clearer in the repro steps below).
After getting this error, the author is unable to save the nested entry and multiple attempts yields the same error, even after refreshing the edit page. Saving the root owner entry does "fix" the issue.
Steps to reproduce
Here is the content model to replicate:
- A section "Section A" with an entry type "Section Entry"
- The "Section Entry" entry type contains a Matrix field "Nested Entries" using all default settings and an entry type "Nested Entry"
- The "Nested Entry" entry type contains a Matrix field "Nested Nested Entries", also using all default settings and an entry type "Nested Nested Entry". The "Nested Nested Entry" type only has a title field.
Here's the project config + Composer files to replicate the content model described above: https://www.dropbox.com/scl/fi/zxuafl8egl2ppfoqg0yng/nested-nested-entry-bug.zip?rlkey=jvy7uy8xprbdms0axs9h9uepu&st=3j3bv30f&dl=0
Here are the steps to reliably reproduce the error w/ the above content model:
- Create an entry in the "Section A" section, with a nested entry in the "Nested Entries" field, that has a nested entry in its "Nested Nested Entries" field.
- Click save in both nested entry slideouts, then save the root owner "Section A" entry.
- After saving the root owner entry, double-click the nested entry card in the "Nested Entries" field to open its slideout. Then double-click the level 2 nested entry in the "Nested Nested Entries" field, and make a content change to that nested entry.
- Without saving the level 2 nested entry, click "Close" in its slideout. Then, click "Save" in its owner's slideout, i.e. the level 1 nested entry.
- After the level 1 nested entry's slideout closes, without saving the root owner section entry double-click the nested entry in the "Nested Entries" field to re-open its slideout. Then double-click the level 2 nested entry's card in the "Nested Nested Entries" field to open that.
- In the level 2 nested entry's slideout (which has unsaved changes), click "Save". At this point two things will happen:
- Craft appears to create a new provisional draft for the level 1 nested entry
- The error toast "The canonical owner element must be the primary owner of the nested element" appears
The level 2 nested entry is now impossible to save unless the root owner entry is saved first.
Here's a screencast of steps 3-8 above: https://share.cleanshot.com/DMBNfjYw
Expected behavior
Being able to save the level 2 nested entry π
Actual behavior
It's possible to get multi-level nested entries into a state where they are not possible to save.
Craft CMS version
5.8.21
PHP version
8.3
Operating system and version
macOS 15.6.1, MS Edge 143.0.3650.66, DDEV v1.24.7
Database type and version
MySQL 8.0.40
Image driver and version
No response
Installed plugins and versions
None