Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Nov 11, 2024

Conversation

ralphjsmit
Copy link
Contributor

@ralphjsmit ralphjsmit commented Nov 8, 2024

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

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@ralphjsmit ralphjsmit changed the title fix: global search fix: global search in SPA mode when switching tenants Nov 8, 2024
@ralphjsmit ralphjsmit marked this pull request as draft November 8, 2024 17:09
@ralphjsmit ralphjsmit marked this pull request as ready for review November 8, 2024 18:24
@danharrin danharrin added the bug Something isn't working label Nov 11, 2024
@danharrin danharrin linked an issue Nov 11, 2024 that may be closed by this pull request
@danharrin danharrin added this to the v3 milestone Nov 11, 2024
@danharrin danharrin merged commit b2bd418 into filamentphp:3.x Nov 11, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

SPA multi-tenancy global search does not respect tenant switch
2 participants