fix: global search in SPA mode when switching tenants #14744
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.