From 6cb0e58faf8e8c6126fbaa1bbf7f593a03a38949 Mon Sep 17 00:00:00 2001
From: Matthew Oliveira <m4olivei@gmail.com>
Date: Wed, 5 Mar 2025 11:11:34 -0500
Subject: [PATCH] Issue #3505182: Avoid rendering a label in the top bar if its
 NULL

---
 .../src/Plugin/TopBarItem/PageContext.php     | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/core/modules/navigation/src/Plugin/TopBarItem/PageContext.php b/core/modules/navigation/src/Plugin/TopBarItem/PageContext.php
index 76448d0f6a65..49078ef95cc0 100644
--- a/core/modules/navigation/src/Plugin/TopBarItem/PageContext.php
+++ b/core/modules/navigation/src/Plugin/TopBarItem/PageContext.php
@@ -85,21 +85,23 @@ public function build(): array {
       return $build;
     }
 
-    $build += [
-      [
-        '#type' => 'component',
-        '#component' => 'navigation:title',
-        '#props' => [
-          'icon' => 'database',
-          'html_tag' => 'span',
-          'modifiers' => ['ellipsis', 'xs'],
-          'extra_classes' => ['top-bar__title'],
-        ],
-        '#slots' => [
-          'content' => $entity->label(),
+    if ($label = $entity->label()) {
+      $build += [
+        [
+          '#type' => 'component',
+          '#component' => 'navigation:title',
+          '#props' => [
+            'icon' => 'database',
+            'html_tag' => 'span',
+            'modifiers' => ['ellipsis', 'xs'],
+            'extra_classes' => ['top-bar__title'],
+          ],
+          '#slots' => [
+            'content' => $label,
+          ],
         ],
-      ],
-    ];
+      ];
+    }
 
     if ($label = $this->getBadgeLabel($entity)) {
       $build += [
-- 
GitLab