Skip to content

Fix element sub-fields in Matrix blocks reading data from other blocks - #1783

Open
jrrdnx wants to merge 2 commits into
craftcms:6.xfrom
reusserdesign:feature/matrix-asset-subfields
Open

jrrdnx wants to merge 2 commits into
craftcms:6.xfrom
reusserdesign:feature/matrix-asset-subfields

Conversation

@jrrdnx

@jrrdnx jrrdnx commented Oct 28, 2026

Copy link
Copy Markdown

Fix element sub-fields for Matrix blocks of mixed types

Element fields resolve sub-field values (e.g. an asset's caption) by the
first index in the node path, but fetch those values from every block that
has them, so the index only lines up when every block has the same type.
Give fields with sub-fields only their own block's data, re-indexed to match.

Include a block's unindexed data with its element sub-fields

Element sub-fields mapped alongside the element field rather than within it
(e.g. an asset's caption next to its image) have no index of their own when a
block isn't in an array, as in a nested Matrix. They were left out of the
block's data, so the sub-field fetch returned null and threw a TypeError. Find
each path's block the same way as _getBlockKey(), so unindexed data belongs to
the first block.

Jarrod D Nix and others added 2 commits October 27, 2026 10:04
Element fields resolve sub-field values (e.g. an asset's caption) by the
first index in the node path, but fetch those values from every block that
has them, so the index only lines up when every block has the same type.
Give fields with sub-fields only their own block's data, re-indexed to match.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Element sub-fields mapped alongside the element field rather than within it
(e.g. an asset's caption next to its image) have no index of their own when a
block isn't in an array, as in a nested Matrix. They were left out of the
block's data, so the sub-field fetch returned null and threw a TypeError. Find
each path's block the same way as _getBlockKey(), so unindexed data belongs to
the first block.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant