diff --git a/src/Http/Livewire/LivewireCollection.php b/src/Http/Livewire/LivewireCollection.php index bb6fd13..3a74176 100644 --- a/src/Http/Livewire/LivewireCollection.php +++ b/src/Http/Livewire/LivewireCollection.php @@ -24,6 +24,9 @@ class LivewireCollection extends Component #[Locked] public $entriesCount; + #[Locked] + public $activeFilters; + #[Locked] public $allowedFilters; @@ -136,6 +139,7 @@ public function render() $entries = $this->entries(); $this->entriesCount = $this->countAllEntries($entries); + $this->activeFilters = $this->getParamsCount(); return view('statamic-livewire-filters::livewire.'.$this->view)->with([ ...$entries, @@ -144,6 +148,6 @@ public function render() public function rendered() { - $this->dispatch('entries-updated', count: $this->entriesCount, active: $this->getParamsCount()); + $this->dispatch('entries-updated', count: $this->entriesCount, active: $this->activeFilters); } } diff --git a/tests/Feature/LivewireCollectionComponentTest.php b/tests/Feature/LivewireCollectionComponentTest.php index 4e4ca2d..d51a6ff 100644 --- a/tests/Feature/LivewireCollectionComponentTest.php +++ b/tests/Feature/LivewireCollectionComponentTest.php @@ -95,6 +95,8 @@ public function it_loads_the_livewire_component_with_parameters_and_changes_them 'title:is' => 'I Love Guitars', 'item_options:is' => 'option1', ]) + ->assertSet('activeFilters', 2) + ->assertSet('entriesCount', 0) ->assertDispatched('entries-updated') ->dispatch('filter-updated', field: 'title',