Skip to content

Commit 4e6c33f

Browse files
committed
Merge branch 'feature/fix-select-rows-query' of https://github.com/Lupennat/laravel-livewire-tables into Lupennat-feature/fix-select-rows-query
2 parents 0ed99ee + 6f220b1 commit 4e6c33f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Traits/WithBulkActions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function resetBulk(): void
6868
*/
6969
public function selectedRowsQuery()
7070
{
71-
return $this->query()->unless(
72-
$this->selectAll,
71+
return $this->query()->when($this->selectAll,
72+
fn ($query) => $this->applySearchFilter($query),
7373
fn ($query) => $query->whereIn($query->qualifyColumn($this->primaryKey), $this->selected)
7474
);
7575
}

tests/DataTableComponentTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,16 @@ public function bulk_actions_defined_through_function()
161161
$this->table->selected[] = 1;
162162
$this->assertEquals(1, $this->table->count());
163163
}
164+
165+
/** @test */
166+
public function bulk_actions_defined_through_with_select_all_function()
167+
{
168+
$this->assertArrayHasKey('count', $this->table->bulkActions);
169+
170+
$this->table->resetFilters();
171+
$this->table->filters['search'] = 'Chico';
172+
$this->assertEquals(1, $this->table->getRowsProperty()->total());
173+
$this->table->selectAll();
174+
$this->assertEquals(1, $this->table->count());
175+
}
164176
}

0 commit comments

Comments
 (0)