Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to `livewire-datatables` will be documented in this file

## 3.2.7 ( 2026-10-01 )

### What's Changed

- Clear browser-retained filter input values after resetting filters or the whole table.
- Keep full table resets compatible with the typed hidden-column state.

## 3.2.6 ( 2026-09-26 )

### What's Changed
Expand Down
4 changes: 2 additions & 2 deletions resources/views/livewire/datatables/datatable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ class="ld-button ld-button--success px-3 py-2 text-xs font-medium tracking-wider
<div class="ld-filter-cell table-cell overflow-hidden align-top">
@if($column['filterable'])
@if( is_iterable($column['filterable']) )
<div wire:key="select-filter-{{ $index }}-{{ count($this->activeSelectFilters[$index] ?? []) }}">
<div wire:key="select-filter-{{ $index }}-{{ $this->filterInputGeneration }}-{{ count($this->activeSelectFilters[$index] ?? []) }}">
@include('datatables::filters.select', ['index' => $index, 'name' => $column['label'], 'options' => $column['filterable']])
</div>
@else
<div wire:key="{{ $index }}">
<div wire:key="filter-{{ $index }}-{{ $this->filterInputGeneration }}">
@include('datatables::filters.' . ($column['filterView'] ?? $column['type']), ['index' => $index, 'name' => $column['label']])
</div>
@endif
Expand Down
5 changes: 4 additions & 1 deletion src/Livewire/LivewireDatatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class LivewireDatatable extends Component
public array $activeBooleanFilters = [];
public array $activeTextFilters = [];
public array $activeNumberFilters = [];
public int $filterInputGeneration = 0;
public array $defaultFilters = [];
public ?bool $hideHeader = false;
public ?bool $hidePagination = false;
Expand Down Expand Up @@ -196,6 +197,7 @@ public function applyToTable($options): void
#[On('resetTable')]
public function resetTable(): void
{
$this->filterInputGeneration++;
$this->perPage = config('livewire-datatables.default_per_page', 10);
$this->sortIndex = $this->defaultSort();
$this->search = null;
Expand All @@ -207,7 +209,7 @@ public function resetTable(): void
$this->activeTextFilters = [];
$this->activeBooleanFilters = [];
$this->activeNumberFilters = [];
$this->hide = null;
$this->hide = [];
$this->resetHiddenColumns();
$this->selected = [];
}
Expand Down Expand Up @@ -1057,6 +1059,7 @@ public function removeSelectFilter($column, $key = null): void

public function clearAllFilters(): void
{
$this->filterInputGeneration++;
$this->activeDateFilters = [];
$this->activeDatetimeFilters = [];
$this->activeTimeFilters = [];
Expand Down
15 changes: 15 additions & 0 deletions tests/LivewireDatatableTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ public function number_filter_clear_actions_are_only_visible_for_entered_values(
->assertDontSeeHtml("wire:click=\"doNumberFilterStart('0', '')\"");
}

#[Test]
public function clearing_filters_replaces_filter_inputs(): void
{
Livewire::test(NumberFilterDummyTable::class)
->assertSeeHtml('wire:key="filter-0-0"')
->call('doNumberFilterStart', 0, 10)
->call('clearAllFilters')
->assertSet('activeNumberFilters', [])
->assertSeeHtml('wire:key="filter-0-1"')
->call('doNumberFilterStart', 0, 20)
->call('resetTable')
->assertSet('activeNumberFilters', [])
->assertSeeHtml('wire:key="filter-0-2"');
}

#[Test]
public function pagination_buttons_have_stable_spacing_and_accessible_state(): void
{
Expand Down
Loading