File tree Expand file tree Collapse file tree 3 files changed +9
-13
lines changed
src/Framework/Features/Navigation Expand file tree Collapse file tree 3 files changed +9
-13
lines changed Original file line number Diff line number Diff line change 66
77use Hyde \Pages \DocumentationPage ;
88
9- use function collect ;
10-
119/**
1210 * @experimental This class may change significantly before its release.
1311 *
@@ -42,16 +40,7 @@ protected function sortSidebarGroupsByLowestPriority(): void
4240 // we do an initial sorting here to order any groups.
4341
4442 $ this ->items = $ this ->items ->sortBy (function (NavItem $ item ): int {
45- return $ item ->hasChildren ()
46- ? $ this ->getLowestPriorityInGroup ($ item )
47- : $ item ->getPriority ();
43+ return $ item ->getPriority ();
4844 })->values ();
4945 }
50-
51- protected function getLowestPriorityInGroup (NavItem $ item ): int
52- {
53- // Todo: Could actually be moved to the NavItem accessor
54-
55- return collect ($ item ->getChildren ())->min (fn (NavItem $ child ): int => $ child ->getPriority ());
56- }
5746}
Original file line number Diff line number Diff line change 1111use Stringable ;
1212use Hyde \Support \Models \ExternalRoute ;
1313
14+ use function collect ;
1415use function is_string ;
1516
1617/**
@@ -135,9 +136,15 @@ public function getLabel(): string
135136
136137 /**
137138 * Get the priority to determine the order of the navigation item.
139+ *
140+ * For dropdowns, this is the priority of the lowest priority child, unless the dropdown has a lower priority.
138141 */
139142 public function getPriority (): int
140143 {
144+ if ($ this ->hasChildren ()) {
145+ return min ($ this ->priority , collect ($ this ->getChildren ())->min (fn (NavItem $ child ): int => $ child ->getPriority ()));
146+ }
147+
141148 return $ this ->priority ;
142149 }
143150
Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ public function testDropdownFacadeWithChildren()
278278
279279 $ item = NavItem::dropdown ('foo ' , $ children );
280280 $ this ->assertSame ($ children , $ item ->getChildren ());
281- $ this ->assertSame (999 , $ item ->getPriority ());
281+ $ this ->assertSame (500 , $ item ->getPriority ());
282282 }
283283
284284 public function testDropdownFacadeWithCustomPriority ()
You can’t perform that action at this time.
0 commit comments