From c533422d32ed0f548da653230875d72eebeedb8e Mon Sep 17 00:00:00 2001 From: Daniel Weaver Date: Mon, 25 Aug 2025 17:06:58 -0400 Subject: [PATCH 1/5] Initial support for expanding/collapsing cp nav --- resources/views/partials/nav-main.blade.php | 118 ++++++++++++++------ src/CP/Navigation/NavBuilder.php | 1 - 2 files changed, 82 insertions(+), 37 deletions(-) diff --git a/resources/views/partials/nav-main.blade.php b/resources/views/partials/nav-main.blade.php index 0cef258e489..0d31b3ab190 100644 --- a/resources/views/partials/nav-main.blade.php +++ b/resources/views/partials/nav-main.blade.php @@ -2,41 +2,87 @@ use function Statamic\trans as __; @endphp -@section('nav-main') - +@section("nav-main") + @stop -@yield('nav-main') +@yield("nav-main") diff --git a/src/CP/Navigation/NavBuilder.php b/src/CP/Navigation/NavBuilder.php index 978eb88c76d..1179471fefb 100644 --- a/src/CP/Navigation/NavBuilder.php +++ b/src/CP/Navigation/NavBuilder.php @@ -102,7 +102,6 @@ protected function trackChildrenClosures() protected function resolveChildrenClosures() { collect($this->items) - ->filter(fn ($item) => $item->isActive() || $this->withHidden) ->each(fn ($item) => $item->resolveChildren()); return $this; From 51c13a072d0cc0467fb4a19d78be58120f5994f7 Mon Sep 17 00:00:00 2001 From: Daniel Weaver Date: Mon, 25 Aug 2025 17:23:50 -0400 Subject: [PATCH 2/5] Fixing tests --- tests/CP/Navigation/ActiveNavItemTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CP/Navigation/ActiveNavItemTest.php b/tests/CP/Navigation/ActiveNavItemTest.php index 8607d52898d..362cb2ef0c3 100644 --- a/tests/CP/Navigation/ActiveNavItemTest.php +++ b/tests/CP/Navigation/ActiveNavItemTest.php @@ -81,8 +81,8 @@ public function it_resolves_all_children_only_once_to_build_caches_for_is_active $this->assertTrue(Blink::has(NavBuilder::UNRESOLVED_CHILDREN_URLS_CACHE_KEY)); $this->assertTrue(Cache::has(NavBuilder::ALL_URLS_CACHE_KEY)); $this->assertTrue(Blink::has(NavBuilder::ALL_URLS_CACHE_KEY)); - $this->assertInstanceOf(Closure::class, $this->getItemByDisplay($nav->get('Content'), 'Collections')->children()); - $this->assertInstanceOf(Closure::class, $this->getItemByDisplay($nav->get('Content'), 'Taxonomies')->children()); + $this->assertInstanceOf(Collection::class, $this->getItemByDisplay($nav->get('Content'), 'Collections')->children()); + $this->assertInstanceOf(Collection::class, $this->getItemByDisplay($nav->get('Content'), 'Taxonomies')->children()); } #[Test] @@ -155,7 +155,7 @@ public function it_builds_core_children_closure_when_not_active() $collections = $this->buildAndGetItem('Content', 'Collections'); $this->assertFalse($collections->isActive()); - $this->assertInstanceOf(Closure::class, $collections->children()); + $this->assertInstanceOf(Collection::class, $collections->children()); } #[Test] @@ -332,7 +332,7 @@ public function it_builds_extension_children_closure_when_not_active() $seoPro = $this->buildAndGetItem('Tools', 'SEO Pro'); $this->assertFalse($seoPro->isActive()); - $this->assertInstanceOf(Closure::class, $seoPro->children()); + $this->assertInstanceOf(Collection::class, $seoPro->children()); } #[Test] From 41066213fce0ced09fa5e9830b1ca1bb29145c2b Mon Sep 17 00:00:00 2001 From: Daniel Weaver Date: Mon, 25 Aug 2025 17:51:06 -0400 Subject: [PATCH 3/5] Linting --- tests/CP/Navigation/ActiveNavItemTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/CP/Navigation/ActiveNavItemTest.php b/tests/CP/Navigation/ActiveNavItemTest.php index 362cb2ef0c3..bebf4021c45 100644 --- a/tests/CP/Navigation/ActiveNavItemTest.php +++ b/tests/CP/Navigation/ActiveNavItemTest.php @@ -2,7 +2,6 @@ namespace Tests\CP\Navigation; -use Closure; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Request; From a44775b3cc22be51a0fa92caa4d9d044957ce65b Mon Sep 17 00:00:00 2001 From: Daniel Weaver Date: Mon, 25 Aug 2025 18:21:00 -0400 Subject: [PATCH 4/5] Aria attributes --- resources/views/partials/nav-main.blade.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/views/partials/nav-main.blade.php b/resources/views/partials/nav-main.blade.php index 0d31b3ab190..56a30ab3876 100644 --- a/resources/views/partials/nav-main.blade.php +++ b/resources/views/partials/nav-main.blade.php @@ -42,6 +42,8 @@ class="group relative"