Cms: Live Preview: Disabled matrix blocks still appear

Created on 29 Mar 2017  Â·  16Comments  Â·  Source: craftcms/cms

Description

Matrix blocks continue to appear in live preview, even when disabled. They don't appear on the front-end (live site) only in live preview.

Note also that (in live preview) they continue to register as part of matrix field's "length". So even if all of the blocks in a matrix field were disabled, if you were checking against the length of that field to hide/show something, it would display even though no blocks were enabled, so the field's "length" should be 0.

Steps to reproduce

  1. Create a matrix block, then disable it
  2. Open live preview
  3. Matrix block will still appear in Live Preview
bug duplicate

Most helpful comment

Just fixed this for Craft 2 as well.

All 16 comments

Just noticed that you have already fixed this on Craft 3 (https://github.com/craftcms/cms/issues/13).

If you'd like to port your fix back to Craft 2, I'd love to have this fixed, but otherwise you can close this issue.

Just fixed this for Craft 2 as well.

good man ;)

Hey Brandon - not sure if this was a side effect of this fix being put in (as i don't recall this behaviour previously), but if I am editing a draft, and view the tokenized preview link, it still shows the disabled Matrix blocks on the page? Live preview behaves as expected, disabled blocks don't show.

@michaelroper Drafts are separate from Live Preview. Can you post as a new issue?

@brandonkelly Hi there! I'm still experiencing this issue on Craft 2.6.3015 - I've disabled a neo module (using https://github.com/benjamminf/craft-neo) and it's still appearing in the Live Preview. Any ideas?
screen shot 2018-04-12 at 11 20 10 am

@kblizeck You’ll have to post that at https://github.com/benjamminf/craft-neo/issues, thanks!

@brandonkelly Oh yea.... Thank you!

I know this issue is closed, but I'm still experiencing this issue on Craft 2.6.3015 with a standard matrix field.
screen shot 2018-05-18 at 21 52 59

@alexbech are you doing anything special when querying for Matrix blocks in your template, besides just entry.myMatrixField.find() (or without the .find()) ?

@brandonkelly I'm eager-loading an image like this:

{% set blocks = entry.frontpageBlocks.find({
      with: [
        'linkCard:image'
      ]
}) %}

It's seems to be related to the eager-loading - took it out, and that fixed the problem.

Yeah… when you eager-load the Matrix blocks, the posted blocks will be overridden with the eager-loaded ones.

That seems like something we could make a special case for though. Will look into it.

Great, this seems to do the trick - but it's a bit convoluted:

{% set blocks = entry.frontpageBlocks.find({
      with: craft.request.isLivePreview ? null : [
        'linkCard:image'
      ]
}) %}

Yep. This was an easy fix - feel free to patch your install with the changes in f44907b while you wait for the next v2 release to go out.

Great, thanks for the prompt response!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

angrybrad picture angrybrad  Â·  3Comments

bitboxfw picture bitboxfw  Â·  3Comments

mccombs picture mccombs  Â·  3Comments

lukebailey picture lukebailey  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments