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

Comments

@jakedohm
Copy link

commented Mar 29, 2017

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

This comment has been minimized.

Copy link
Author

commented Mar 29, 2017

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 brandonkelly self-assigned this Apr 4, 2017
@brandonkelly

This comment has been minimized.

Copy link
Member

commented Apr 4, 2017

Just fixed this for Craft 2 as well.

@narration-sd

This comment has been minimized.

Copy link
Contributor

commented Apr 4, 2017

good man ;)

@michaelroper

This comment has been minimized.

Copy link

commented Apr 24, 2017

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

This comment has been minimized.

Copy link
Member

commented Apr 24, 2017

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

@kblizeck

This comment has been minimized.

Copy link

commented Apr 12, 2018

@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

This comment has been minimized.

Copy link
Member

commented Apr 12, 2018

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

@kblizeck

This comment has been minimized.

Copy link

commented Apr 13, 2018

@brandonkelly Oh yea.... Thank you!

@alexbech

This comment has been minimized.

Copy link

commented May 18, 2018

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

This comment has been minimized.

Copy link
Member

commented May 22, 2018

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

@alexbech

This comment has been minimized.

Copy link

commented May 22, 2018

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

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

This comment has been minimized.

Copy link

commented May 22, 2018

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

@brandonkelly

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

commented May 22, 2018

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 added a commit that referenced this issue May 22, 2018
@brandonkelly

This comment has been minimized.

Copy link
Member

commented May 22, 2018

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

This comment has been minimized.

Copy link

commented May 22, 2018

Great, thanks for the prompt response!

brandonkelly added a commit that referenced this issue May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.