Issue #3042216 by johndevman, lauriii, tim.plunkett: Only add .layout-builder-block to blocks when in the Layout Builder UI

merge-requests/1119/head
Alex Pott 2019-04-13 15:25:59 -07:00
parent 508a63e7cd
commit cf3d779799
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
5 changed files with 4 additions and 8 deletions

View File

@ -247,6 +247,7 @@ class LayoutBuilder extends RenderElement implements ContainerFactoryPluginInter
if (!empty($build[$region])) {
foreach (Element::children($build[$region]) as $uuid) {
$build[$region][$uuid]['#attributes']['class'][] = 'draggable';
$build[$region][$uuid]['#attributes']['class'][] = 'layout-builder-block';
$build[$region][$uuid]['#attributes']['data-layout-block-uuid'] = $uuid;
$build[$region][$uuid]['#attributes']['data-layout-builder-highlight-id'] = $this->blockUpdateHighlightId($uuid);
$build[$region][$uuid]['#contextual_links'] = [

View File

@ -117,7 +117,6 @@ class BlockComponentRenderArray implements EventSubscriberInterface {
'#base_plugin_id' => $block->getBaseId(),
'#derivative_plugin_id' => $block->getDerivativeId(),
'#weight' => $event->getComponent()->getWeight(),
'#attributes' => ['class' => ['layout-builder-block']],
'content' => $content,
];

View File

@ -225,6 +225,7 @@ class LayoutBuilderTest extends BrowserTestBase {
]));
$this->drupalGet('node/1');
$assert_session->elementNotExists('css', '.layout-builder-block');
$assert_session->pageTextContains('The first node body');
$assert_session->pageTextNotContains('Powered by Drupal');
$assert_session->linkNotExists('Layout');
@ -245,6 +246,8 @@ class LayoutBuilderTest extends BrowserTestBase {
$assert_session->elementsCount('css', '.field--name-body', 1);
// The extra field is only present once.
$assert_session->pageTextContainsOnce('Placeholder for the "Extra label" field');
// Blocks have layout builder specific block class.
$assert_session->elementExists('css', '.layout-builder-block');
// Save the defaults.
$page->pressButton('Save layout');
$assert_session->addressEquals("$field_ui_prefix/display/default");

View File

@ -119,7 +119,6 @@ class BlockComponentRenderArrayTest extends UnitTestCase {
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
'class' => ['layout-builder-block'],
],
];
@ -195,7 +194,6 @@ class BlockComponentRenderArrayTest extends UnitTestCase {
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
'class' => ['layout-builder-block'],
],
];
@ -325,7 +323,6 @@ class BlockComponentRenderArrayTest extends UnitTestCase {
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
'class' => ['layout-builder-block'],
],
];
@ -385,7 +382,6 @@ class BlockComponentRenderArrayTest extends UnitTestCase {
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_string,
'class' => ['layout-builder-block'],
],
];
$expected_build['content']['#markup'] = $placeholder_string;

View File

@ -112,7 +112,6 @@ class SectionRenderTest extends UnitTestCase {
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
'class' => ['layout-builder-block'],
],
'#cache' => [
'contexts' => [],
@ -196,7 +195,6 @@ class SectionRenderTest extends UnitTestCase {
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
'class' => ['layout-builder-block'],
],
'#cache' => [
'contexts' => [],
@ -256,7 +254,6 @@ class SectionRenderTest extends UnitTestCase {
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
'class' => ['layout-builder-block'],
],
'#cache' => [
'contexts' => [],