diff --git a/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DescriptionExtraField.php b/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DescriptionExtraField.php index 546a504713..37bb76f92a 100755 --- a/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DescriptionExtraField.php +++ b/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DescriptionExtraField.php @@ -88,13 +88,16 @@ public function getLabel() { * {@inheritdoc} */ public function viewElements(ContentEntityInterface $entity) { + // If we have no renderable text wee don't need a title. + $text = $this->getRenderableText($entity); + $title = !empty($text[0]['#text']) ? $this->getRenderableTitle($entity) : ''; // Display event description using "text_featured_media" pattern. $build = [ '#type' => 'pattern', '#id' => 'text_featured_media', '#fields' => [ - 'title' => $this->getRenderableTitle($entity), - 'text' => $this->getRenderableText($entity), + 'title' => $title, + 'text' => $text, ], ]; diff --git a/tests/src/Functional/ContentEventRenderTest.php b/tests/src/Functional/ContentEventRenderTest.php index 65ee9868a0..62bd7042b9 100644 --- a/tests/src/Functional/ContentEventRenderTest.php +++ b/tests/src/Functional/ContentEventRenderTest.php @@ -496,6 +496,9 @@ public function testEventRendering(): void { $this->assertSession()->linkNotExistsExact('Main link for media items'); $this->assertSession()->pageTextNotContains('More media links'); + // Assert "Description" title is not rendered unless there is a body text. + $this->assertSession()->pageTextNotContains('Description'); + // Assert "Full text", "Featured media", "Featured media legend" fields // (these fields have to be filled all together). $node->set('body', 'Event full text');