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.13k stars 2.95k forks source link

SPA multi-tenancy global search does not respect tenant switch #14196

Closed Plytas closed 9 hours ago

Plytas commented 2 months ago

Package

filament/filament

Package Version

v3.2.110

Laravel Version

v11.22.0

Livewire Version

v3.5.6

PHP Version

PHP 8.3.7

Problem description

When using global search in SPA mode with multi-tenancy after switching to a different tenant, the results are displayed from a previous tenant. I believe that global search component is not reloaded and still uses initial tenant scope.

https://github.com/user-attachments/assets/6ab988f1-c4ca-4467-a313-f97a0b45023b

In this video I am on Team 1 tenant. I type post in global search and observe This post is on Team 1 record. After switching to tenant Team 2 I type post in global search and still observe This post is on Team 1 record.

Expected behavior

I expected search to work the same as it does in non SPA mode. Switching tenant and using global search should correctly scope the query to new tenant.

This is how it works in non SPA mode.

https://github.com/user-attachments/assets/59eb1104-409c-4886-8e2f-6e383b1cd0c4

Steps to reproduce

  1. Clone the repo
  2. composer install
  3. php artisan migrate --seed
  4. Log in to the app on / route with the credentials: email - test@example.com, password - password
  5. Type post in the global search bar
  6. Observe that This post is on Team 1 is visible
  7. Switch the tenant to Team 2
  8. Type post in the global search bar
  9. Observe that This post is on Team 1 is still visible

Reproduction repository (issue will be closed if this is not valid)

https://github.com/Plytas/filament-spa-search

Relevant log output

No response

Donate 💰 to fund this issue

Fund with Polar

renatofrota commented 1 month ago

related discussion: https://github.com/filamentphp/filament/discussions/13742

Plytas commented 1 month ago

Thanks @renatofrota! I could've sworn I looked through issues and discussions, but couldn't find anything related.