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

Plugin blocks cannot set their own attributes when put in the layout.

$
0
0

Problem/Motivation

Normally, when creating block plugins, one can return an #attributes from the build() method. If that happens, the attributes are being added to the block's wrapper.

It looks like this logic is located here: https://git.drupalcode.org/project/drupal/blob/8.8.x/core/modules/block/...

It doesn't work if the block has been put inside the layout, through the layout_builder. I consider it a bug, as anyone would expect the same behavior here, and it will surely break some custom plugin blocks relying on this feature.

Proposed resolution

Apply the same logic inside the BlockComponentRenderArray as it is in the BlockViewBuilder, to make #attributes work with the layout_builder.

Remaining tasks

Review the patch.

API changes

If anyone used #attributes to put attributes in the content of their block, instead of the block's wrapper, this change will probably break something for him. The weight of this issue is reduced by the fact, that this person would have to create this block plugin only to work in the layout builder, as outside of it, he would quickly notice that it doesn't work as expected.


Viewing all articles
Browse latest Browse all 292451

Trending Articles



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