Subnavigation sidebars do not respect SPA mode
Package
filament/filament
Package Version
v3.2.90
Laravel Version
v11.10.0
Livewire Version
v.3.5.0
PHP Version
PHP 8.2.20
Problem description
When adding a subnavigation in a panel which has SPA mode turned on, the subnavigation links always do a full page load regardless. There is no way to get them to do a page load SPA style.
Expected behavior
If the panel is in SPA mode, subnavigation links by default should also load in SPA mode
Steps to reproduce
Create a panel and add ->spa() to the panel configuration
Add a subnavigation to a resource or page
Notice how the subnavigation links always do a full page load and never contain wire:navigate
Reproduction repository (issue will be closed if this is not valid)
https://github.com/Jamesking56/filament-spa-subnavigation-bug
Relevant log output
No response
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!
I got the same issue, the navigation menu is not persistent in spa mode
Avoid using this:
NavigationItem::make()
->label('Test')
->url('test/123')
Instead, use:
NavigationItem::make()
->label('Test')
->url(route('your_route_name'))
By using the route() helper, the system will correctly identify it as an application route and handle it as expected.
The reason for this is that the system determines whether a URL belongs to the application by checking if it starts with the app's root URL:
function is_app_url(string $url): bool
{
return str($url)->startsWith(request()->root());
}
Not a bug, IMO. This seems to be the expected functionality @zepfietje, regards!
Thanks @borjajimnz!