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
[X] Code style has been fixed by running the composer cs command.
[X] Changes have been tested to not break existing functionality.
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 anx-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
composer cs
command.