From bc08b60876da6184af1693c4e8b02309df9978a6 Mon Sep 17 00:00:00 2001
From: nod_ <nod_@598310.no-reply.drupal.org>
Date: Wed, 29 Jan 2025 09:50:19 +0100
Subject: [PATCH] Issue #3493410 by plopesc, catch, smustgrave: Consider a more
 substantial shortcuts placeholder

---
 .../navigation/src/Hook/NavigationHooks.php   |  8 -------
 .../Plugin/Block/NavigationShortcutsBlock.php | 12 ++++++++++-
 ...azy-builder-lazyLinks--Shortcuts.html.twig | 21 -------------------
 .../FunctionalJavascript/PerformanceTest.php  |  2 +-
 4 files changed, 12 insertions(+), 31 deletions(-)
 delete mode 100644 core/modules/navigation/templates/big-pipe-interface-preview--navigation-shortcut-lazy-builder-lazyLinks--Shortcuts.html.twig

diff --git a/core/modules/navigation/src/Hook/NavigationHooks.php b/core/modules/navigation/src/Hook/NavigationHooks.php
index eb1ddb5b3a27..8192c9e02bcc 100644
--- a/core/modules/navigation/src/Hook/NavigationHooks.php
+++ b/core/modules/navigation/src/Hook/NavigationHooks.php
@@ -80,14 +80,6 @@ public function theme($existing, $type, $theme, $path) : array {
     $items['top_bar'] = ['render element' => 'element'];
     $items['top_bar_local_tasks'] = ['variables' => ['local_tasks' => []]];
     $items['top_bar_local_task'] = ['variables' => ['link' => []]];
-    $items['big_pipe_interface_preview__navigation_shortcut_lazy_builder_lazyLinks__Shortcuts'] = [
-      'variables' => [
-        'callback' => NULL,
-        'arguments' => NULL,
-        'preview' => NULL,
-      ],
-      'base hook' => 'big_pipe_interface_preview',
-    ];
     $items['block__navigation'] = ['render element' => 'elements', 'base hook' => 'block'];
     $items['navigation_menu'] = [
       'base hook' => 'menu',
diff --git a/core/modules/navigation/src/Plugin/Block/NavigationShortcutsBlock.php b/core/modules/navigation/src/Plugin/Block/NavigationShortcutsBlock.php
index 2ec0b1424adb..e5e2f7f4526d 100644
--- a/core/modules/navigation/src/Plugin/Block/NavigationShortcutsBlock.php
+++ b/core/modules/navigation/src/Plugin/Block/NavigationShortcutsBlock.php
@@ -81,7 +81,17 @@ public function build(): array {
           'contexts' => ['user'],
         ],
         '#lazy_builder_preview' => [
-          '#markup' => '<a href="#" class="toolbar-tray-lazy-placeholder-link">&nbsp;</a>',
+          [
+            '#theme' => 'navigation_menu',
+            '#menu_name' => 'shortcuts',
+            '#title' => $this->configuration['label'],
+            '#items' => [
+              [
+                'title' => $this->configuration['label'],
+                'class' => 'shortcuts',
+              ],
+            ],
+          ],
         ],
       ],
     ];
diff --git a/core/modules/navigation/templates/big-pipe-interface-preview--navigation-shortcut-lazy-builder-lazyLinks--Shortcuts.html.twig b/core/modules/navigation/templates/big-pipe-interface-preview--navigation-shortcut-lazy-builder-lazyLinks--Shortcuts.html.twig
deleted file mode 100644
index 2994e7d32809..000000000000
--- a/core/modules/navigation/templates/big-pipe-interface-preview--navigation-shortcut-lazy-builder-lazyLinks--Shortcuts.html.twig
+++ /dev/null
@@ -1,21 +0,0 @@
-{#
-/**
- * @file
- * Placeholder content for the shortcuts menu. This is used to eliminate layout
- * shifts as BigPipe injects data.
- */
-#}
-
-{% include 'navigation:toolbar-button' with {
-  attributes: create_attribute(),
-  modifiers: [
-    'expand--side',
-    'collapsible',
-  ],
-  extra_classes: [
-    'invisible',
-    'toolbar-popover__control',
-  ],
-  icon: 'shortcuts',
-  text: 'Shortcuts'|t,
-} only %}
diff --git a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php
index 3b7500ae2075..5a25d2a71eec 100644
--- a/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php
+++ b/core/modules/navigation/tests/src/FunctionalJavascript/PerformanceTest.php
@@ -72,7 +72,7 @@ public function testLogin(): void {
     $recorded_queries = $performance_data->getQueries();
     $this->assertSame($expected_queries, $recorded_queries);
     $this->assertSame(4, $performance_data->getQueryCount());
-    $this->assertSame(60, $performance_data->getCacheGetCount());
+    $this->assertSame(61, $performance_data->getCacheGetCount());
     $this->assertSame(2, $performance_data->getCacheSetCount());
     $this->assertSame(0, $performance_data->getCacheDeleteCount());
     $this->assertSame(2, $performance_data->getCacheTagChecksumCount());
-- 
GitLab