Skip to content
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

don't set cache results to empty array for nested matrix entry with b… #14954

Closed

Conversation

i-just
Copy link
Contributor

@i-just i-just commented May 7, 2024

Description

In a matrix in a matrix setup where both matrix fields are in “as inline-editable blocks” mode and the nested matrix has min entries set to at least 1, the title is hidden, and URI format references the slug; if you add a new top-level matrix entry, the draft won’t be saved because of slug validation issue.

Replication steps:

  • create matrixEt1 entry type with “show the title field” and “show the skug field” disabled
  • create myMatrix1field, type: matrix, entry type: matrixEt1, URI: sth/{slug}, min entries: 1, view mode: blocks
  • create a matrixEt2 entry type with the myMatrix1 field in it
  • create myMatrix2 field, type: matrix, entry type matrixEt2, view mode: blocks
  • create a contentBuilder entry type with the myMatrix2 field in it
  • create a section that uses the contentBuilder entry type
  • create an entry in the above section & add an entry (block) to the myMatrix2

The issue is triggered because when the entry (block) is added, the empty value is being cached, causing the nested entry to be an empty “skeleton” one without a title or slug, which prevents the slug from being correctly set based on the title attribute.

If you reload the page after adding the entry (block), the draft will start being saved as expected.

This PR excludes nested matrix entries from being cached as empty array when normalising field value from request if it’s a nested entry in the blocks view mode.

Screenshot of the replication setup:
Screenshot 2024-05-07 at 17 27 42

Related issues

#14947

Unverified

This user has not yet uploaded their public signing key.
…locks view
@i-just i-just requested a review from brandonkelly May 7, 2024 16:32
@brandonkelly
Copy link
Member

@i-just Thanks for figuring this out! I hadn’t been able to reproduce with the steps listed in #14947, but could with these ones.

I was able to resolve it in a different way, by delaying the time when those initial blocks get auto-created until after the Matrix field is fully initialized. (07e944d)

@brandonkelly brandonkelly deleted the bugfix/14947-nested-inline-matrix-entries-and-caching branch May 7, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants