Skip to content

Commit

Permalink
[FIX] Placeholder not working on Filter::number (#1536)
Browse files Browse the repository at this point in the history
* Fix placeholder not working on filter number

* Improve tests checking for placeholder
  • Loading branch information
dansysanalyst authored May 8, 2024
1 parent 02834d3 commit 10a51a7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

@php
$fieldClassName = data_get($filter, 'className');
$field = data_get($filter, 'field');
$componentAttributes = (array) data_get($filter, 'attributes');
$defaultAttributes = $fieldClassName::getWireAttributes($field, array_merge($filter, (array)$column));
$filterClasses = Arr::toCssClasses([data_get($theme, 'inputClass'), data_get($column, 'headerClass'), 'power_grid']);
$placeholder = data_get($filter, 'placeholder');
$params = array_merge([...data_get($filter, 'attributes'), ...$defaultAttributes, $filterClasses], $filter);
@endphp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
'column' => '',
])
@php
$fieldClassName = data_get($filter, 'className');
$field = data_get($filter, 'field');
$componentAttributes = (array) data_get($filter, 'attributes');
Expand All @@ -14,6 +16,8 @@
$filterClasses = Arr::toCssClasses([data_get($theme, 'inputClass'), data_get($column, 'headerClass'), 'power_grid']);
$placeholder = data_get($filter, 'placeholder');
$params = array_merge([...data_get($filter, 'attributes'), ...$defaultAttributes, $filterClasses], $filter);
@endphp

Expand Down
31 changes: 15 additions & 16 deletions tests/Feature/Filters/FilterMultipleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
public function filters(): array
{
return [
Filter::number('price')
->thousands('.')
->decimal(','),
Filter::inputText('name')->operators(),
Filter::number('price')->thousands('.')->decimal(','),
Filter::number('price_BRL')->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.') ->decimal(','),
Filter::number('price') ->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.') ->decimal(','),
Filter::inputText('name')->placeholder('dish_name_xyz_placeholder')->operators(),
Filter::number('price')->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.')->decimal(','),
Filter::boolean('in_stock'),
];
}
Expand All @@ -28,11 +27,10 @@ public function filters(): array
public function filters(): array
{
return [
Filter::number('price')
->thousands('.')
->decimal(','),
Filter::inputText('name')->operators(),
Filter::number('price')->thousands('.')->decimal(','),
Filter::number('price_BRL')->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.') ->decimal(','),
Filter::number('price') ->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.') ->decimal(','),
Filter::inputText('name')->placeholder('dish_name_xyz_placeholder')->operators(),
Filter::number('price')->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.')->decimal(','),
Filter::boolean('in_stock'),
];
}
Expand All @@ -42,11 +40,9 @@ public function filters(): array
public function filters(): array
{
return [
Filter::number('price')
->thousands('.')
->decimal(','),
Filter::inputText('name')->operators(),
Filter::number('price')->thousands('.')->decimal(','),
Filter::number('price_BRL') ->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.') ->decimal(','),
Filter::inputText('dish_name')->placeholder('dish_name_xyz_placeholder')->operators(),
Filter::number('price')->placeholder('min_xyz_placeholder', 'max_xyz_placeholder')->thousands('.')->decimal(','),
Filter::boolean('in_stock'),
];
}
Expand Down Expand Up @@ -92,11 +88,14 @@ public function filters(): array
]);
}

$component->assertSee('Barco-Sushi da Sueli');
$component->assertSee('Barco-Sushi da Sueli')
->assertSeeHtml('dish_name_xyz_placeholder');

$filters = array_merge($component->filters, filterNumber('price', '80.00', '100'));

$component->set('filters', $filters)
->assertSeeHtml('placeholder="min_xyz_placeholder"')
->assertSeeHtml('placeholder="max_xyz_placeholder"')
->assertDontSee('Barco-Sushi da Sueli')
->assertSee('Barco-Sushi Simples')
->assertDontSee('Polpetone Filé Mignon')
Expand Down

0 comments on commit 10a51a7

Please sign in to comment.