Problem/Motivation

With live preview, we can add blocks to the layout builder, make updates, and see content changes in real-time. This is great.

We have discovered that this does not play nice with Field Blocks. When these blocks are added, such as the body field, it throws an Ajax error due to missing context on the entity.

Drupal\Component\Plugin\Exception\MissingValueContextException: Required contexts without a value: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 155 of core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).

Steps to reproduce

With Live Preview, add a field block via Layout Builder. I.e. a body field. Produces Ajax error.

Proposed resolution

Review and adjust for the missing context.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Nugg created an issue. See original summary.

thestevelavigne’s picture

Title: Ajax error when adding a Field Block to layout builder with Live Preview. » Ajax error when adding a Field Block to layout builder with live preview
dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new4.33 KB

Here's a patch that fixes this issue in my limited testing.

@Nugg Can you give it a try?

  • dsnopek committed c1f24b1 on 8.x-2.x
    Issue #3201720 by dsnopek: Ajax error when adding a Field Block to...
dsnopek’s picture

Status: Needs review » Fixed

On Slack, @Nugg let me know that the patch is for working for him! So, committed :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.