filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.

Home Page:https://filamentphp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

image

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!
Fund with Polar

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

Is there some way to archive this effect, or this this can be made behind a flag ?

Will you accept PR for something like this?

image

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

@danharrin

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

Hi, here is a picture of what im trying to make

image

Is this possible ?

I suggest using clusters instead