diff --git a/resources/views/components/tools/filters/select.blade.php b/resources/views/components/tools/filters/select.blade.php index d3f5dfe1a..9a0ca9683 100644 --- a/resources/views/components/tools/filters/select.blade.php +++ b/resources/views/components/tools/filters/select.blade.php @@ -5,15 +5,16 @@ 'rounded-md shadow-sm' => $isTailwind, 'inline' => $isBootstrap, ])> - getWireMethod('filterComponents.'.$filter->getKey()) !!} {{ + $filterInputAttributes->merge() + ->class([ + 'block w-full transition duration-150 ease-in-out rounded-md shadow-sm focus:ring focus:ring-opacity-50' => $isTailwind && ($filterInputAttributes['default-styling'] ?? true), + 'border-gray-300 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-800 dark:text-white dark:border-gray-600' => $isTailwind && ($filterInputAttributes['default-colors'] ?? true), + 'form-control' => $isBootstrap4 && ($filterInputAttributes['default-styling'] ?? true), + 'form-select' => $isBootstrap5 && ($filterInputAttributes['default-styling'] ?? true), ]) - > + ->except(['default-styling','default-colors']) + }}> @foreach($filter->getOptions() as $key => $value) @if (is_iterable($value)) diff --git a/src/Views/Filters/SelectFilter.php b/src/Views/Filters/SelectFilter.php index dc564fd22..4066f91cb 100644 --- a/src/Views/Filters/SelectFilter.php +++ b/src/Views/Filters/SelectFilter.php @@ -49,4 +49,15 @@ public function getFilterPillValue($value): array|string|bool|null ->mapWithKeys(fn ($options, $optgroupLabel) => is_iterable($options) ? $options : [$optgroupLabel => $options])[$value] ?? null; } + + protected function getCoreInputAttributes(): array + { + $attributes = array_merge(parent::getCoreInputAttributes(), + [ + 'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'select'), + ]); + ksort($attributes); + + return $attributes; + } } diff --git a/tests/Unit/Views/Filters/SelectFilterTest.php b/tests/Unit/Views/Filters/SelectFilterTest.php index c95653019..43fb49561 100644 --- a/tests/Unit/Views/Filters/SelectFilterTest.php +++ b/tests/Unit/Views/Filters/SelectFilterTest.php @@ -13,6 +13,10 @@ protected function setUp(): void { parent::setUp(); self::$filterInstance = SelectFilter::make('Active')->options(['Cartman', 'Tux', 'May', 'Ben', 'Chico']); + self::$extraFilterInputAttributes = [ + 'wire:key' => 'test123-filter-select-active', + ]; + } public function test_array_setup(): array