Problem/Motivation

With Layout Builder Modal enabled, if you edit the default layout of a content type, contextual links are not rendered on blocks. This essentially makes it impossible to remove blocks from the default layout.

In Drupal logs you'll find:

Error: Call to a member function get() on null in _layout_builder_modal_dialog_options() (line 102 of /app/web/modules/contrib/layout_builder_modal/layout_builder_modal.module)

Here's a video of what I'm seeing:

https://www.loom.com/share/7d0f6ad94b3140819488d51965163c5e

Steps to reproduce

  • Edit any content type where Layout Builder is enabled and there are blocks placed in the default layout. Go to the Manage display tab.
  • Click the Manage layout button
  • Hover over any block. You will not see contextual links.
  • Inspect the markup. You'll see the links are not rendered.
  • Review your Drupal log. You'll see the error I posted above

Proposed resolution

The problem is clear when you look at _layout_builder_modal_dialog_options(). There is an expectation that we're editing a node, but the default layout is not a node. It seems that the only reason we're using Node:load() is to get the $layout. So is there some other way to do this that doesn't assume the existence of a node?

Remaining tasks

User interface changes

API changes

Data model changes

Comments

maskedjellybean created an issue. See original summary.

maskedjellybean’s picture

Oh wow, I just realized this is caused by code I introduced in https://www.drupal.org/project/layout_builder_modal/issues/3196147 and doesn't affect those who haven't applied my patch from that issue.

maskedjellybean’s picture

Status: Active » Closed (works as designed)