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

Live Preview: Disabled matrix blocks still appear #1576

Closed
jakedohm opened this issue Mar 29, 2017 · 16 comments
Closed

Live Preview: Disabled matrix blocks still appear #1576

jakedohm opened this issue Mar 29, 2017 · 16 comments
Assignees

Comments

@jakedohm
Copy link

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
@jakedohm
Copy link
Author

Just noticed that you have already fixed this on Craft 3 (#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.

@brandonkelly
Copy link
Member

Just fixed this for Craft 2 as well.

@narration-sd
Copy link
Contributor

good man ;)

@michaelroper
Copy link

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.

@brandonkelly
Copy link
Member

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

@kblizeck
Copy link

@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

@brandonkelly
Copy link
Member

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

@kblizeck
Copy link

@brandonkelly Oh yea.... Thank you!

@alexbech
Copy link

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

@brandonkelly
Copy link
Member

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

@alexbech
Copy link

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

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

@alexbech
Copy link

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

@brandonkelly
Copy link
Member

brandonkelly commented May 22, 2018

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.

@alexbech
Copy link

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'
      ]
}) %}

@brandonkelly
Copy link
Member

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.

@alexbech
Copy link

Great, thanks for the prompt response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants