Filter shows selected enum option even when all enum options are unchecked
Laravel v9.41.0 Nova v4.19.3 Nova Enum Field v3.0.1
Issue: The Filter dropdown shows that an enum filter is selected even when filters have been unchecked.
Steps to reproduce:
- Check off 1 enum filter option
- See "Selected Filter Counter" change to "1" and background color change from "white" to "green"
- Uncheck the enum filter option
- See "Selected Filter Counter" stay at "1" and background color stays "green"
Expected results:
- See "Selected Filter Counter" show no counter and background color change back to "white"
Seemed to have missed this over the holidays! Happy with a PR that resolves this 😄
Hey, do you still need PR for that? I can try to do it.
Sure!
I already found that workaround for that is not to use "0" as value of enum. eg. const Admin = 0;.
UPDATE:
For me it's rather Nova itself bug then this package. Take this as simple example - it gives exactly the same behaviour:
<?php
namespace App\Nova\Filters;
use Laravel\Nova\Filters\BooleanFilter;
use Laravel\Nova\Http\Requests\NovaRequest;
class ExampleType extends BooleanFilter
{
public function apply(NovaRequest $request, $query, $value)
{
return $query;
}
public function options(NovaRequest $request)
{
return [0,1,2];
}
}
What do you guys think? In above example you can change return in options method to [1,2] and it starts to work as expected.
Closing this if this behaviour is present in Nova itself. Thanks for the investigation!