Issue #3090174 by tim.plunkett, henriklarsson: Data attribute 'layout-content-preview-placeholder-label' exists outside LB UI

merge-requests/2419/head
Alex Pott 2019-11-15 21:39:03 +00:00
parent bd584c5719
commit a22c3c4580
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
3 changed files with 15 additions and 24 deletions

View File

@ -120,20 +120,23 @@ class BlockComponentRenderArray implements EventSubscriberInterface {
'content' => $content,
];
if ($block instanceof PreviewFallbackInterface) {
$preview_fallback_string = $block->getPreviewFallbackString();
}
else {
$preview_fallback_string = $this->t('"@block" block', ['@block' => $block->label()]);
}
// @todo Use new label methods so
// data-layout-content-preview-placeholder-label doesn't have to use
// preview fallback in https://www.drupal.org/node/2025649.
$build['#attributes']['data-layout-content-preview-placeholder-label'] = $preview_fallback_string;
if ($event->inPreview()) {
if ($block instanceof PreviewFallbackInterface) {
$preview_fallback_string = $block->getPreviewFallbackString();
}
else {
$preview_fallback_string = $this->t('"@block" block', ['@block' => $block->label()]);
}
// @todo Use new label methods so
// data-layout-content-preview-placeholder-label doesn't have to use
// preview fallback in https://www.drupal.org/node/2025649.
$build['#attributes']['data-layout-content-preview-placeholder-label'] = $preview_fallback_string;
if ($is_content_empty && $is_placeholder_ready) {
$build['content']['#markup'] = $this->t('Placeholder for the @preview_fallback', ['@preview_fallback' => $block->getPreviewFallbackString()]);
if ($is_content_empty && $is_placeholder_ready) {
$build['content']['#markup'] = $this->t('Placeholder for the @preview_fallback', ['@preview_fallback' => $block->getPreviewFallbackString()]);
}
}
$event->setBuild($build);
}
}

View File

@ -117,9 +117,6 @@ class BlockComponentRenderArrayTest extends UnitTestCase {
'#base_plugin_id' => 'block_plugin_id',
'#derivative_plugin_id' => NULL,
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
],
];
$expected_cache = $expected_build + [
@ -192,9 +189,6 @@ class BlockComponentRenderArrayTest extends UnitTestCase {
'#base_plugin_id' => 'block_plugin_id',
'#derivative_plugin_id' => NULL,
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
],
];
$expected_cache = $expected_build + [

View File

@ -110,9 +110,6 @@ class SectionRenderTest extends UnitTestCase {
'#base_plugin_id' => 'block_plugin_id',
'#derivative_plugin_id' => NULL,
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
],
'#cache' => [
'contexts' => [],
'tags' => [],
@ -252,9 +249,6 @@ class SectionRenderTest extends UnitTestCase {
'#base_plugin_id' => 'block_plugin_id',
'#derivative_plugin_id' => NULL,
'content' => $block_content,
'#attributes' => [
'data-layout-content-preview-placeholder-label' => $placeholder_label,
],
'#cache' => [
'contexts' => [],
'tags' => [],