mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Fix menu item sorting by using sortBy() instead of sort() (#18220)
Changed Collection::sort() to Collection::sortBy() in getUserMenuItems() and getTenantMenuItems() methods. The sort() method expects a comparison callback but was being called with a single-parameter callback that returns a value, resulting in unpredictable sorting order. sortBy() correctly sorts by the returned value. This ensures menu items are consistently ordered by their sort value.
This commit is contained in:
@@ -383,7 +383,7 @@ trait HasTenancy
|
||||
fn (Collection $items): Collection => $items->put('register', $this->getTenantRegistrationMenuItem()),
|
||||
)
|
||||
->filter(fn (Action $item): bool => $item->isVisible())
|
||||
->sort(fn (Action $item): int => $item->getSort())
|
||||
->sortBy(fn (Action $item): int => $item->getSort())
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ trait HasUserMenu
|
||||
fn (Collection $items): Collection => $items->put('logout', $this->getUserLogoutMenuItem()),
|
||||
)
|
||||
->filter(fn (Action $item): bool => $item->isVisible())
|
||||
->sort(fn (Action $item): int => $item->getSort())
|
||||
->sortBy(fn (Action $item): int => $item->getSort())
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user