From 60363198ca8f9621d028e884d3ce1add80567a23 Mon Sep 17 00:00:00 2001 From: Pawel K <39682172+Pawel-IT@users.noreply.github.com> Date: Tue, 3 Jun 2025 17:20:33 -0600 Subject: [PATCH 1/2] Add persistsFiltersInSession() function It wasn't clear that filters persist in session by default unlike tables. The persistsFiltersInSession() chain method is also not available on dashboard. So added section on how you can overwrite this method if you don't want filters persisted. --- packages/panels/docs/05-dashboard.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/panels/docs/05-dashboard.md b/packages/panels/docs/05-dashboard.md index e3942cf9b2..92894a9f1e 100644 --- a/packages/panels/docs/05-dashboard.md +++ b/packages/panels/docs/05-dashboard.md @@ -215,6 +215,17 @@ class Dashboard extends BaseDashboard Handling data from the filter action is the same as handling data from the filters header form, except that the data is validated before being passed to the widget. The `InteractsWithPageFilters` trait still applies. +### Persisting Filter State In Session + +By default the filters applied will persist in the session on page reload. To change this add the the `persistsFiltersInSession()` method to your Dashboard.php file: + +```php +public function persistsFiltersInSession(): bool +{ + return false; +} +``` + ## Disabling the default widgets By default, two widgets are displayed on the dashboard. These widgets can be disabled by updating the `widgets()` array of the [configuration](configuration): From c857f408ba73d5024c0f9f57790ebd23c8531351 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Sat, 7 Jun 2025 08:51:54 +0100 Subject: [PATCH 2/2] Update 05-dashboard.md --- packages/panels/docs/05-dashboard.md | 30 ++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/panels/docs/05-dashboard.md b/packages/panels/docs/05-dashboard.md index 92894a9f1e..594dfb850f 100644 --- a/packages/panels/docs/05-dashboard.md +++ b/packages/panels/docs/05-dashboard.md @@ -215,14 +215,36 @@ class Dashboard extends BaseDashboard Handling data from the filter action is the same as handling data from the filters header form, except that the data is validated before being passed to the widget. The `InteractsWithPageFilters` trait still applies. -### Persisting Filter State In Session +### Persisting widget filters in the user's session -By default the filters applied will persist in the session on page reload. To change this add the the `persistsFiltersInSession()` method to your Dashboard.php file: +By default, the dashboard filters applied will persist in the user's session between page loads. To disable this, override the `$persistsFiltersInSession` property in the dashboard page class: ```php -public function persistsFiltersInSession(): bool +use Filament\Pages\Dashboard as BaseDashboard; +use Filament\Pages\Dashboard\Concerns\HasFiltersForm; + +class Dashboard extends BaseDashboard { - return false; + use HasFiltersForm; + + protected bool $persistsFiltersInSession = false; +} +``` + +Alternatively, override the `persistsFiltersInSession()` method in the dashboard page class: + +```php +use Filament\Pages\Dashboard as BaseDashboard; +use Filament\Pages\Dashboard\Concerns\HasFiltersForm; + +class Dashboard extends BaseDashboard +{ + use HasFiltersForm; + + public function persistsFiltersInSession(): bool + { + return false; + } } ```