diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 2c166df999e417b7954ab4b45b491540d2fab054..ce55fca7bf6bcd9efec75c010b601bd63dbad768 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -29,7 +29,7 @@ function template_preprocess_admin_block_content(&$variables) { $variables['compact'] = system_admin_compact_mode(); foreach ($variables['content'] as $key => $item) { $variables['content'][$key]['link'] = Link::fromTextAndUrl($item['title'], $item['url'])->toString(); - if (!$variables['compact'] && isset($item['description'])) { + if (!$variables['compact'] && !empty($item['description'])) { $variables['content'][$key]['description'] = ['#markup' => $item['description']]; } else { diff --git a/core/modules/system/tests/modules/menu_test/menu_test.links.menu.yml b/core/modules/system/tests/modules/menu_test/menu_test.links.menu.yml index 2bdb59865a3f677a41a0512822b0ea1485242b64..9ba1b8f1bf4f9863c78237a7b2f3434719ca6c92 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.links.menu.yml +++ b/core/modules/system/tests/modules/menu_test/menu_test.links.menu.yml @@ -89,3 +89,8 @@ menu_test.access_check: title: 'Test custom route access check' route_name: menu_test.router_test_session menu_name: account + +menu_test.admin_description: + title: 'Test custom admin block without description' + parent: system.admin_config_content + route_name: menu_test.menu_name_test diff --git a/core/modules/system/tests/src/Functional/System/AdminTest.php b/core/modules/system/tests/src/Functional/System/AdminTest.php index 261b4b00a2cff9776febfd444f651c19ce6f38ae..0d4b798cd94dac26574d10be3f18bc1425834d67 100644 --- a/core/modules/system/tests/src/Functional/System/AdminTest.php +++ b/core/modules/system/tests/src/Functional/System/AdminTest.php @@ -31,7 +31,7 @@ class AdminTest extends BrowserTestBase { * * @var array */ - protected static $modules = ['locale']; + protected static $modules = ['locale', 'menu_test']; /** * {@inheritdoc} @@ -182,4 +182,17 @@ public function testCompactMode() { $this->assertNull($session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode persists off new requests.'); } + /** + * Tests admin config page blocks without descriptions. + */ + public function testConfigBlocksDescription(): void { + // Go to Config administration page. + $this->drupalGet('admin/config'); + $this->assertSession()->statusCodeEquals(200); + // Validates the custom block without description. + $this->assertSession()->pageTextContains('Test custom admin block without description'); + // Validates an empty description block. + $this->assertSession()->elementNotExists('xpath', '//dd[@class="list-group__description"][not(text())]'); + } + }