From 3652bb272b1933c9bf2736ab8fff7cc2adef6dd0 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Mon, 15 Sep 2025 16:16:10 +0100 Subject: [PATCH 1/3] Ensure nav customizations apply to breadcrumbs --- src/CP/Breadcrumbs/Breadcrumbs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CP/Breadcrumbs/Breadcrumbs.php b/src/CP/Breadcrumbs/Breadcrumbs.php index e7af3e6109a..317506c9ba6 100644 --- a/src/CP/Breadcrumbs/Breadcrumbs.php +++ b/src/CP/Breadcrumbs/Breadcrumbs.php @@ -17,7 +17,7 @@ public static function push(Breadcrumb $breadcrumb) public static function build(): array { - $breadcrumbs = Nav::build(preferences: false)->map(function (array $section): ?array { + $breadcrumbs = Nav::build()->map(function (array $section): ?array { $primaryNavItem = $section['items']->first(function (NavItem $navItem) { return $navItem->isActive(); }); From ad022a7d6da2f30041fb03c6626c4f51f33616a0 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Mon, 15 Sep 2025 16:52:08 +0100 Subject: [PATCH 2/3] delete test --- tests/CP/Breadcrumbs/BreadcrumbsTest.php | 35 ------------------------ 1 file changed, 35 deletions(-) diff --git a/tests/CP/Breadcrumbs/BreadcrumbsTest.php b/tests/CP/Breadcrumbs/BreadcrumbsTest.php index 7d0e130111f..13628423d2f 100644 --- a/tests/CP/Breadcrumbs/BreadcrumbsTest.php +++ b/tests/CP/Breadcrumbs/BreadcrumbsTest.php @@ -101,41 +101,6 @@ public function it_builds_breadcrumbs_correctly_for_content_show_page() ], $breadcrumbs); } - #[Test] - public function it_ignores_nav_preferences_when_building_breadcrumbs() - { - $this->actingAs($user = User::make()->makeSuper())->get(cp_route('dashboard')); - - $user->preferences([ - 'nav' => [ - 'content' => [ - 'reorder' => [ - 'top_level::dashboard', - ], - 'items' => [ - 'top_level::dashboard' => [ - 'action' => '@move', - 'display' => 'The Dashboard', - 'icon' => 'browser-com', - ], - ], - ], - ], - ]); - - $breadcrumbs = Breadcrumbs::build(); - - // None of the preferences should be applied to the breadcrumbs. - $this->assertEquals([ - new Breadcrumb( - text: 'Dashboard', - url: 'http://localhost/cp/dashboard', - icon: 'dashboard', - links: [] - ), - ], $breadcrumbs); - } - #[Test] public function it_doesnt_build_breadcrumbs_for_pages_not_in_the_nav() { From 711d1e9f1dc537c89b2aad05f61ae14807dcfdca Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Mon, 15 Sep 2025 16:54:22 +0100 Subject: [PATCH 3/3] actually, repurpose instead of deleting --- tests/CP/Breadcrumbs/BreadcrumbsTest.php | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/CP/Breadcrumbs/BreadcrumbsTest.php b/tests/CP/Breadcrumbs/BreadcrumbsTest.php index 13628423d2f..1fe17b4c6ff 100644 --- a/tests/CP/Breadcrumbs/BreadcrumbsTest.php +++ b/tests/CP/Breadcrumbs/BreadcrumbsTest.php @@ -101,6 +101,46 @@ public function it_builds_breadcrumbs_correctly_for_content_show_page() ], $breadcrumbs); } + #[Test] + public function it_uses_nav_preferences_when_building_breadcrumbs() + { + $this->actingAs($user = User::make()->makeSuper())->get(cp_route('dashboard')); + + $user->preferences([ + 'nav' => [ + 'content' => [ + 'reorder' => [ + 'top_level::dashboard', + ], + 'items' => [ + 'top_level::dashboard' => [ + 'action' => '@move', + 'display' => 'The Dashboard', + 'icon' => 'browser-com', + ], + ], + ], + ], + ]); + + $breadcrumbs = Breadcrumbs::build(); + + $this->assertEquals([ + new Breadcrumb( + text: 'The Dashboard', + url: 'http://localhost/cp/dashboard', + icon: 'browser-com', + links: [ + ['icon' => 'collections', 'text' => 'Collections', 'url' => 'http://localhost/cp/collections'], + ['icon' => 'navigation', 'text' => 'Navigation', 'url' => 'http://localhost/cp/navigation'], + ['icon' => 'taxonomies', 'text' => 'Taxonomies', 'url' => 'http://localhost/cp/taxonomies'], + ['icon' => 'assets', 'text' => 'Assets', 'url' => 'http://localhost/cp/assets'], + ['icon' => 'globals', 'text' => 'Globals', 'url' => 'http://localhost/cp/globals'], + ] + ), + ], $breadcrumbs); + } + #[Test] public function it_doesnt_build_breadcrumbs_for_pages_not_in_the_nav() {