Skip to content

Commit

Permalink
Add activeFilters property
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jan 27, 2025
1 parent 219f11f commit b59898b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Http/Livewire/LivewireCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class LivewireCollection extends Component
#[Locked]
public $entriesCount;

#[Locked]
public $activeFilters;

#[Locked]
public $allowedFilters;

Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
}
2 changes: 2 additions & 0 deletions tests/Feature/LivewireCollectionComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit b59898b

Please sign in to comment.