diff --git a/core/modules/navigation/src/NavigationRenderer.php b/core/modules/navigation/src/NavigationRenderer.php index 8e29298092d668cbf999bfbbe601b4de25891087..60a7c15ee4f0ed2944ad82cfc12d10bf753d9f51 100644 --- a/core/modules/navigation/src/NavigationRenderer.php +++ b/core/modules/navigation/src/NavigationRenderer.php @@ -130,15 +130,16 @@ public function doBuildNavigation($build): array { if ($storage) { foreach ($storage->getSections() as $delta => $section) { $build[$delta] = $section->toRenderArray([]); - $build[$delta]['#cache']['contexts'] = ['user.permissions', 'theme', 'languages:language_interface']; } } // The render array is built based on decisions made by SectionStorage // plugins and therefore it needs to depend on the accumulated // cacheability of those decisions. - $cacheability->addCacheableDependency($logo_settings) - ->addCacheableDependency($this->configFactory->get('navigation.block_layout')); - $cacheability->applyTo($build); + CacheableMetadata::createFromRenderArray($build) + ->addCacheableDependency($cacheability) + ->addCacheableDependency($logo_settings) + ->addCacheableDependency($this->configFactory->get('navigation.block_layout')) + ->applyTo($build); $module_path = $this->requestStack->getCurrentRequest()->getBasePath() . '/' . $this->moduleExtensionList->getPath('navigation'); $asset_url = $module_path . '/assets/fonts/inter-var.woff2';