Small problems with navigationSort

I want to reorder menu links in the sidebar navigation. Since they are sorted alphabeticaly I used navigationSort as per documentation
protected static ?int $navigationSort = 0;
protected static ?int $navigationSort = 0;
but link I wanted to move stayed on the same place. Only time it moved was if I used negative values. I've then tried and added navigationSort value for each item in the menu and I was able to reorder the list. Now, question is was this the correct way of ordering items, and what you do if you have more links? You need to manually add values or is there some other method I didn't found.
2 Replies
fagner
fagner2mo ago
Yes, you discovered the correct way! The behavior you found is expected. Here's how navigationSort works in Filament: How Sorting Works Filament sorts navigation items like this: 1 By navigation group (navigationGroup) 2 By navigationSort (ascending order: -10, 0, 10, 20, etc) 3 Alphabetically (when navigationSort is not defined or is equal) So you should verify that the sorting will depend first on the ordering of your navigationGroup in the sidebar, and you can define this in your panel provider.
Zlatiborac
ZlatiboracOP2mo ago
Thanks a lot. I did found that I could use groups but wanted to be sure for ordering inside the group. So any link added must be manually changed to fit where I want.

Did you find this page helpful?