craftcms / cms

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

1787 doesn't seem fixed: Live Preview doesn't update eager-loaded matrix fields #4873

Closed MattWilcox closed 5 years ago

MattWilcox commented 5 years ago

Description

This issue has been closed: https://github.com/craftcms/cms/issues/1787

This does not appear to be fixed in 3.3.0.1; I have exactly the same issue as always; when a Matrix is eager loaded, the live preview does not reflect updates to the changes in a Matrix field.

Sample code that is not working with Live Preview:

{% do eagerLoadElements(entry, [
'mixedContent.images:images',
'mixedContent.entries:entries.listingImage',
'mixedContent.files:files'
]) %}

{% for block in entry.mixedContent.all() %} {% include '_partials/mixedcontent/' ~ block.type ignore missing %} {% endfor %}

Steps to reproduce

  1. Create a template with the above code and associated Matrix field
  2. Go to Live Preview and edit the content of the Matrix
  3. Watch the page flash, but no changes be reflected

Additional info

brandonkelly commented 5 years ago

@MattWilcox whatever your eagerLoadElements function is doing (that’s not a standard Craft function), it’s not actually eager-loading anything from the looks of it, otherwise you would be getting an error when you try to do entry.mixedContent.all(). Once mixedContent is eager-loaded, it will return an array, not an element query object with an all() method.

MattWilcox commented 5 years ago

@brandonkelly Thanks! You have just uncovered a snippet of code that I've just pulled over from my Craft2 builds and forgot was not standard. It's from Eager Beaver... https://github.com/nystudio107/eagerbeaver