Skip to content

Commit

Permalink
fix(filters): fix triggers for some filters (#1178)
Browse files Browse the repository at this point in the history
No more livewire attribute .lazy available in livewire 3. Use blur instead
  • Loading branch information
jamesRUS52 authored Sep 26, 2023
1 parent b845843 commit 8b46816
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Components/Filters/FilterBoolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static function getWireAttributes(string $field, string $title): array
{
return collect()
->put('selectAttributes', new ComponentAttributeBag([
'wire:input.lazy' => 'filterBoolean(\'' . $field . '\', $event.target.value, \'' . $title . '\')',
'wire:model.lazy' => 'filters.boolean.' . $field,
'wire:input.blur' => 'filterBoolean(\'' . $field . '\', $event.target.value, \'' . $title . '\')',
'wire:model.blur' => 'filters.boolean.' . $field,
]))->toArray();
}
}
4 changes: 2 additions & 2 deletions src/Components/Filters/FilterInputText.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static function getWireAttributes(string $field, string $title): array
{
return collect()
->put('selectAttributes', new ComponentAttributeBag([
'wire:model.lazy' => 'filters.input_text_options.' . $field,
'wire:input.lazy' => 'filterInputTextOptions(\'' . $field . '\', $event.target.value)',
'wire:model.blur' => 'filters.input_text_options.' . $field,
'wire:input.blur' => 'filterInputTextOptions(\'' . $field . '\', $event.target.value)',
]))
->put('inputAttributes', new ComponentAttributeBag([
'wire:model.live.debounce.700ms' => 'filters.input_text.' . $field,
Expand Down
16 changes: 8 additions & 8 deletions tests/Feature/Filters/FilterBooleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
])
->call($params->theme)
->assertSee('Em Estoque')
->assertSeeHtml('wire:input.lazy="filterBoolean(\'in_stock\', $event.target.value, \'Em Estoque\')"');
->assertSeeHtml('wire:input.blur="filterBoolean(\'in_stock\', $event.target.value, \'Em Estoque\')"');

expect($component->filters)
->toBeEmpty();
Expand Down Expand Up @@ -80,7 +80,7 @@ public function filters(): array
$component = livewire($component)
->call($params->theme)
->assertSee('Em Estoque')
->assertSeeHtml('wire:input.lazy="filterBoolean(\'in_stock\', $event.target.value, \'Em Estoque\')"');
->assertSeeHtml('wire:input.blur="filterBoolean(\'in_stock\', $event.target.value, \'Em Estoque\')"');

expect($component->filters)
->toBeEmpty();
Expand All @@ -102,7 +102,7 @@ public function filters(): array
])
->call($theme)
->assertSee('In Stock')
->assertSeeHtml('wire:input.lazy="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');
->assertSeeHtml('wire:input.blur="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');

expect($component->filters)
->toBeEmpty();
Expand Down Expand Up @@ -140,7 +140,7 @@ public function filters(): array
])
->call($theme)
->assertSee('In Stock')
->assertSeeHtml('wire:input.lazy="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');
->assertSeeHtml('wire:input.blur="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');

expect($component->filters)
->toBeEmpty();
Expand Down Expand Up @@ -180,8 +180,8 @@ public function filters(): array
],
])
->call($theme)
->assertSeeHtml('wire:input.lazy="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"')
->assertSeeHtml('wire:model.lazy="filters.boolean.in_stock"');
->assertSeeHtml('wire:input.blur="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"')
->assertSeeHtml('wire:model.blur="filters.boolean.in_stock"');

expect($component->filters)
->toBeEmpty();
Expand Down Expand Up @@ -216,7 +216,7 @@ public function filters(): array
it('properly filters by bool true - using collection - custom builder - using tablename in field', function (string $component, string $theme) {
$component = livewire($component)
->call($theme)
->assertSeeHtml('wire:input.lazy="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');
->assertSeeHtml('wire:input.blur="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');

expect($component->filters)
->toBeEmpty();
Expand Down Expand Up @@ -290,7 +290,7 @@ public function filters(): array
])
->call($theme)
->assertSee('In Stock')
->assertSeeHtml('wire:input.lazy="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');
->assertSeeHtml('wire:input.blur="filterBoolean(\'in_stock\', $event.target.value, \'In Stock\')"');

expect($component->filters)
->toMatchArray([]);
Expand Down

0 comments on commit 8b46816

Please sign in to comment.