Navigation order does not respect the `$navigationSort` parameter when used with `$navigationGroup`
peter-mw opened this issue · comments
Package
filament/filament
Package Version
v3.2
Laravel Version
v11
Livewire Version
v3
PHP Version
PHP 8.2
Problem description
Navigation does not respect the $navigationSort
parameter when used with $navigationGroup
Expected behavior
Expected to page named Two
to be between One
and Three
Steps to reproduce
Open the file app/Filament/Pages/Two.php
Remove line protected static ?string $navigationGroup = 'Two';
and order is corect, but with this line the page Two
does after Three
Reproduction repository
https://github.com/peter-mw/filament-nav-order-bug
Relevant log output
No log
Donate 💰 to fund this issue
- You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
- 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
- Thank you in advance for helping us make maintenance sustainable!
All groups go after ungrouped items, we do not break up the ungrouped items with groups as it could result in weird behaviour where you expect part of the group to be in one place and another part to be in another
No sorry, it would introduce too much complexity into the navigation logic.
You can use navigation groups with blank labels to achieve a similar affect if you define the navigation()
function yourself
Will try, thanks for the suggestions
hi @danharrin
Can we have something like protected static ?array $acceptNavigationGroups = ['Two']
Parameter in the main menu acceptNavigationGroups
?
It will look like this
class One extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.one';
protected static ?int $navigationSort = 1;
protected static ?array $acceptNavigationGroups = ['Two'];
}
class Two extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.two';
protected static ?int $navigationSort = 2;
protected static ?string $navigationGroup = 'Two';
}
What do you think ?
Or even better, an option is to research recursive menus with the KNP Menu builder, https://github.com/KnpLabs/KnpMenu
It allows unlimited nested menus.
There is no technical reasons in PHP to not support nested menus. It's all frontend design work that is nearly impossible to balance and account for all combinations
How to have a menu item appear inside another menu?
To make menu Two appear inside menu One, is not possbible at the moment
We can have new navigationParent
parameter to solve this issue.
For example:
protected static ?string $navigationParent = 'One';
The class would look like this:
class TwoOne extends Page
{
protected static ?int $navigationSort = 2;
protected static ?string $navigationParent = 'One';
}
class ThreeOne extends Page
{
protected static ?int $navigationSort = 3;
protected static ?string $navigationParent = 'One';
}
The problem is how to have a single menu item, then a dynamic menu inside the single menu, and then another single menu item.
Can you suggest solution ?
I dont understand what that would do, sorry
I suggest using clusters instead
navigationParentItem
already exists btw https://filamentphp.com/docs/3.x/panels/navigation#grouping-navigation-items-under-other-items