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?
Comments
Comment #2
maskedjellybeanOh 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.
Comment #3
maskedjellybean