filament icon indicating copy to clipboard operation
filament copied to clipboard

Subnavigation sidebars do not respect SPA mode

Open Jamesking56 opened this issue 1 year ago • 1 comments

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

Jamesking56 avatar Jun 29 '24 22:06 Jamesking56

I got the same issue, the navigation menu is not persistent in spa mode

robiokidenis avatar Sep 03 '24 22:09 robiokidenis

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!

borjajimnz avatar Jan 03 '25 23:01 borjajimnz

Thanks @borjajimnz!

danharrin avatar Jun 21 '25 15:06 danharrin