Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293250

Breadcrumbs block within Layout Builder causes errors when moving blocks

$
0
0

Problem/Motivation

Layout Builder throws errors when the system Breadcrumbs block is in a layout and any blocks are moved. Further, after moving the Breadcrumbs block, the "Move" contextual link stops working.

The error looks something like this:

InvalidArgumentException: Invalid UUID "first" in Drupal\layout_builder\Section->getComponent() (line 177 of /var/www/web/core/modules/layout_builder/src/Section.php).

Steps to reproduce

Simple

  1. Do a Standard Install
  2. Enable Layout Builder
  3. Configure Basic Page content type to use Layout Builder
  4. Add a Breadcrumbs block to the Basic Page layout
  5. Move any block via drag-and-drop in the Basic Page layout through the Layout Builder UI
  6. Go to the Recent Log Messages and see something about an invalid UUID

More Interesting

  1. Do a Standard Install
  2. Enable Layout Builder
  3. Configure Basic Page content type to use Layout Builder
  4. Add a Breadcrumbs block to the Basic Page layout
  5. Move any block to a different section via drag-and-drop in the Basic Page layout through the Layout Builder UI
  6. Click the "Move" contextual link for the any block. Instead of the offscreen dialog flying in, the throbber will just give up.
  7. Right-click the "Move" contextual link for any block and open the link in a new tab. WSOD.

Proposed resolution

The error results for the Breadcrumbs getting built and rebuilt as part of the layout builder preview. It tries to build breadcrumbs for the layout_builder.move_block_form route and the title callback is called with bad arguments.

Current Proposal

We can add a LayoutBuilderBreadcrumbBuilder class and a layout_builder.breadcrumb to build breadcrumbs on routes related to moving blocks. See #20.

Older proposals

Old Proposal 1
Add some defensive coding into \Drupal\layout_builder\Form\MoveBlockForm::title to confirm that the uuid argument looks like a uuid before using it in a getComponent() call. Return some sort of placeholder text as the title instead.

Old Proposal 2
SystemBreadcrumbBlock::build could vary depending on context. This would depend on #3027653: Allow block plugins to determine if they are being previewed getting fixed first.

Old Proposal 3
SystemBreadcrumbBlock::build do a special case when the route name is layout_builder.move_block

Other proposals?

Remaining tasks

Write tests (this is started in #14 but can probably be improved)
Add a fix

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Original Report

When using the drag and drop interface for Layout Builder, dragging a custom block generates the following error:

InvalidArgumentException: Invalid UUID "first" in Drupal\layout_builder\Section->getComponent() (line 177 of /var/www/web/core/modules/layout_builder/src/Section.php).

Where "first" is the label of the region inside the section. This is thrown on any move, whether between sections or not. There is no further backtrace listed, but I was able to track it back to MoveBlockForm::title. This error does not get thrown if I open the Move Block Form from the contextual menu.

The only module we have installed I know of that does anything with this form is layout_builder_restrictions, but I am not seeing anything in that code that would do this.

Just being an old code rat, I am not conversant enough with the JS Drag and Drop interface to be able to troubleshoot this further without some help, and I haven't seen this in any other issue queues.


Viewing all articles
Browse latest Browse all 293250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>