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.
https://filamentphp.com
MIT License
19.47k stars 2.97k forks source link

fix: global search in SPA mode when switching tenants #14744

Closed ralphjsmit closed 2 weeks ago

ralphjsmit commented 2 weeks ago

Description

This PR fixes the global search issue, where the GlobalSearch is not reset after switching tenants in SPA mode. The reason that it was not taking the new Filament::getTenant() is that the component was inside an x-persist, so that means that it was not re-mounted and that it would keep the previous URL path also with the previous tenant inside it. As Livewire mocks the original request, this resulted in the previous tenant being used for search.

This solution changes it by adding the current tenant ID to the x-persist identifier, so that the topbar end is persisted when navigating within the same tenant, but is refreshed and re-mounted when switching tenants.

Another benefit is that this will re-load the notifications and the user menu, so in case the user avatar or something changed, that would also benefit from the re-load and not getting persisted.

PS: Also, I'm not sure if x-persist is officially documented, so perhaps better to switch to @persist (though you likely have had your reasons/preference).

Thanks!

Functional changes